{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 142,
   "metadata": {},
   "outputs": [],
   "source": [
    "def evaluate_association_rules(rules_to_evaluate,test_datas):\n",
    "    \"\"\"\n",
    "    Parameters：\n",
    "        rules_to_evaluate：要评估的关联规则（推荐规则） list((rule_a,rule_b))\n",
    "        test_datas：测试用的数据集 dataframe\n",
    "\n",
    "    Returns：\n",
    "        关联规则（推荐规则）在测试集上的平均准确率\n",
    "    \"\"\"\n",
    "    point_sum = 0\n",
    "    miss = 0\n",
    "    for rule_a,rule_b in rules_to_evaluate:\n",
    "        set_rule_a = set(rule_a)\n",
    "        set_rule_b = set(rule_b)  \n",
    "        \n",
    "        num_a = 0\n",
    "        num_b = 0\n",
    "        \n",
    "        for test_data in test_datas.value:\n",
    "            set_test_data = set(test_data)\n",
    "            if set_rule_a.issubset(set_test_data):\n",
    "                num_a += 1\n",
    "                if set_rule_b.issubset(set_test_data):\n",
    "                    num_b += 1\n",
    "        if num_a:\n",
    "            point_sum += num_b / num_a\n",
    "        else:\n",
    "            miss += 1\n",
    "    print(miss,' rules miss')\n",
    "    return point_sum / len(rules_to_evaluate)\n",
    "    "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### 函数测试"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10339\n",
      "<class 'generator'>\n",
      "-------------挖掘频繁项集---------------\n",
      "                fluent_patterns   support\n",
      "0                      [102392]  0.315795\n",
      "1                        [8892]  0.269272\n",
      "2                [102392, 8892]  0.142083\n",
      "3                [139252, 8892]  0.141213\n",
      "4        [102392, 139252, 8892]  0.086952\n",
      "5               [5267730, 8892]  0.144405\n",
      "6       [102392, 5267730, 8892]  0.086179\n",
      "7       [139252, 5267730, 8892]  0.103008\n",
      "8                     [4312482]  0.205726\n",
      "9             [102392, 4312482]  0.099139\n",
      "10              [8892, 4312482]  0.103105\n",
      "11      [139252, 8892, 4312482]  0.075249\n",
      "12     [5267730, 8892, 4312482]  0.075152\n",
      "13            [139252, 4312482]  0.123803\n",
      "14           [5267730, 4312482]  0.120708\n",
      "15   [139252, 5267730, 4312482]  0.091208\n",
      "16            [130412, 4312482]  0.097011\n",
      "17    [139252, 130412, 4312482]  0.076700\n",
      "18   [5267730, 130412, 4312482]  0.072831\n",
      "19                     [135652]  0.194893\n",
      "20             [102392, 135652]  0.088306\n",
      "21               [8892, 135652]  0.088016\n",
      "22            [4312482, 135652]  0.088306\n",
      "23             [139252, 135652]  0.102911\n",
      "24            [5267730, 135652]  0.099913\n",
      "25    [139252, 5267730, 135652]  0.072638\n",
      "26             [130412, 135652]  0.084631\n",
      "27                    [4316382]  0.188510\n",
      "28            [102392, 4316382]  0.097688\n",
      "29              [8892, 4316382]  0.106780\n",
      "..                          ...       ...\n",
      "416                      [5989]  0.080569\n",
      "417                      [1539]  0.077087\n",
      "418                     [17632]  0.076410\n",
      "419                      [8812]  0.120418\n",
      "420                [8892, 8812]  0.071961\n",
      "421              [102392, 8812]  0.073218\n",
      "422                      [5069]  0.089177\n",
      "423                     [23432]  0.077957\n",
      "424                     [97912]  0.071477\n",
      "425                      [5793]  0.115001\n",
      "426                      [1733]  0.110359\n",
      "427                       [184]  0.094980\n",
      "428                      [7452]  0.128929\n",
      "429               [78552, 7452]  0.079602\n",
      "430                      [2572]  0.090047\n",
      "431                       [963]  0.082987\n",
      "432                      [5800]  0.188896\n",
      "433              [102392, 5800]  0.106297\n",
      "434              [139252, 5800]  0.085598\n",
      "435             [5267730, 5800]  0.085598\n",
      "436                [8892, 5800]  0.085501\n",
      "437                [5997, 5800]  0.107554\n",
      "438                [3450, 5800]  0.073798\n",
      "439                [3461, 5800]  0.082503\n",
      "440                      [6001]  0.096431\n",
      "441                      [2580]  0.133088\n",
      "442              [102392, 2580]  0.075056\n",
      "443                      [4188]  0.080085\n",
      "444                      [5070]  0.074765\n",
      "445                      [1650]  0.085018\n",
      "\n",
      "[446 rows x 2 columns]\n",
      "--------------频繁项集------------------\n",
      "----------------关联规则-------------------\n",
      "                         rules_a           rules_b  confidence\n",
      "0     (4316482, 4316382, 139252)         (5267730)    0.899207\n",
      "1             (5267750, 4316382)         (5267730)    0.898389\n",
      "2             (4762754, 4316382)         (5267730)    0.893303\n",
      "3        (4316382, 8892, 139252)         (5267730)    0.885057\n",
      "4     (4316482, 5267730, 130412)          (139252)    0.878021\n",
      "5             (4312482, 4316382)         (5267730)    0.872222\n",
      "6      (130412, 4316382, 139252)         (5267730)    0.872043\n",
      "7             (4316482, 4316382)         (5267730)    0.871673\n",
      "8    (4316482, 5267730, 4316382)          (139252)    0.865867\n",
      "9              (134912, 4316382)         (5267730)    0.861111\n",
      "10             (4316482, 134912)          (139252)    0.859954\n",
      "11             (4316442, 139252)         (5267730)    0.856187\n",
      "12             (4316482, 102252)          (139252)    0.855803\n",
      "13               (4316382, 8892)         (5267730)    0.854167\n",
      "14             (134932, 4316382)         (5267730)    0.853922\n",
      "15             (4316382, 139252)         (5267730)    0.852015\n",
      "16                        (1587)            (1586)    0.851810\n",
      "17             (130412, 4316382)         (5267730)    0.850442\n",
      "18    (130412, 5267730, 4316382)          (139252)    0.843913\n",
      "19             (4762754, 139252)         (5267730)    0.841991\n",
      "20            (4316482, 4316382)          (139252)    0.839354\n",
      "21             (4316482, 130412)          (139252)    0.839080\n",
      "22             (102392, 4316382)         (5267730)    0.833663\n",
      "23               (4316482, 8892)          (139252)    0.833503\n",
      "24            (4316482, 5267730)          (139252)    0.830818\n",
      "25            (4762754, 4316382)          (139252)    0.826334\n",
      "26       (130412, 5267730, 8892)          (139252)    0.825556\n",
      "27             (4316482, 102392)          (139252)    0.824462\n",
      "28            (4762754, 5267730)         (4316382)    0.823222\n",
      "29             (5267730, 102252)          (139252)    0.823171\n",
      "..                           ...               ...         ...\n",
      "229               (102392, 5997)         (5267730)    0.614686\n",
      "230           (4316482, 5267730)         (4312482)    0.613979\n",
      "231                     (139252)         (5267730)    0.613882\n",
      "232                       (8752)            (8892)    0.613048\n",
      "233               (102392, 8892)          (139252)    0.611981\n",
      "234            (102392, 5267730)            (8892)    0.611531\n",
      "235                    (4762734)         (5267730)    0.611004\n",
      "236             (102392, 102792)         (5267730)    0.609715\n",
      "237                    (5267750)         (4312482)    0.609058\n",
      "238           (5267730, 4316382)            (8892)    0.608780\n",
      "239             (134912, 130412)         (4316382)    0.608514\n",
      "240                       (8812)          (102392)    0.608032\n",
      "241             (130412, 139252)         (4316382)    0.607843\n",
      "242            (4312482, 139252)            (8892)    0.607812\n",
      "243           (4316482, 5267730)            (8892)    0.607625\n",
      "244                   (24097891)         (5267730)    0.607020\n",
      "245                     (134912)         (5267730)    0.606968\n",
      "246           (4312482, 5267730)         (5267750)    0.606571\n",
      "247               (102392, 8892)         (5267730)    0.606535\n",
      "248                   (22503880)        (22718131)    0.606184\n",
      "249           (4316482, 5267730)  (130412, 139252)    0.606037\n",
      "250            (5267730, 139252)            (8892)    0.605114\n",
      "251                       (1586)            (1587)    0.604819\n",
      "252               (8792, 102252)          (102392)    0.604459\n",
      "253                       (8772)            (6301)    0.604183\n",
      "254           (4312482, 5267730)          (130412)    0.603365\n",
      "255             (102392, 139252)            (8892)    0.603356\n",
      "256              (5267730, 8892)          (130412)    0.602813\n",
      "257                      (78352)          (102392)    0.602158\n",
      "258                    (4312482)          (139252)    0.601787\n",
      "\n",
      "[259 rows x 3 columns]\n",
      "----------------关联规则-------------------\n"
     ]
    }
   ],
   "source": [
    "# 导入所需模块\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import json\n",
    "import fp_growth_py3 as fpg\n",
    "import matplotlib.pyplot as plt\n",
    "import pylab as pl\n",
    "from collections import defaultdict\n",
    "import association_rules "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "51432"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 读入测试数据集\n",
    "filepath='./test_data/user_following_animation.json'\n",
    "data=pd.read_json(filepath,lines=True)\n",
    "user_info = pd.read_csv(\"test_data/bilibili_crawler_user_info.csv\",names = ['id','mid','name','sex','sign','the_rank','level','jointime','moral','silence','birthday','coins','fans_badge','role','title','desc','vip_type','vip_status'])\n",
    "\n",
    "len(user_info)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "51424"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "user_info.drop(user_info[user_info.vip_type.isna() | user_info.the_rank.isna() | user_info.level.isna()].index.tolist(),inplace=True) # 将vip_type、the_rank、level有NaN的行去掉\n",
    "len(user_info)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 设置权重字典\n",
    "add_rules={'the_rank':{10000:1,20000:2,25000:3,30000:4},'level':{'3':1,'4':2,'5':3,'6':4},'vip_type':{0:0,1:1,2:2}}\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "db                                                       7\n",
      "key                                         finished_users\n",
      "size                                                507576\n",
      "ttl                                                     -1\n",
      "type                                                   set\n",
      "value    [330817737, 74775, 259640193, 24774761, 540994...\n",
      "Name: 4504, dtype: object\n"
     ]
    }
   ],
   "source": [
    "# 去除一下异常数据\n",
    "for index,row in data.iterrows():\n",
    "    try:\n",
    "        int(row.key)\n",
    "    except:\n",
    "        print(row)\n",
    "        data.drop(index,inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "def user_power(data,rules,user_info):\n",
    "    \"\"\"\n",
    "    params:\n",
    "        data:用户收藏ID数据集\n",
    "        rules:权重规则\n",
    "        user_info:用户信息数据集\n",
    "    return:新数据集\n",
    "        \n",
    "    \"\"\"\n",
    "    new_data = pd.DataFrame(columns=data.columns)\n",
    "    for index,row in data.iterrows():\n",
    "        info = user_info[user_info.mid == int(row.key)]\n",
    "\n",
    "        if len(info):\n",
    "            the_power = rules['the_rank'][info.the_rank.values[0]] + rules['level'][info.level.values[0]] + rules['vip_type'][info.vip_type.values[0]]\n",
    "        else:  # len(info)==0 说明在user_info中没有这个用户的相关数据\n",
    "            the_power = 1\n",
    "#         print(the_power)\n",
    "        for i in range(the_power):\n",
    "            new_data = new_data.append(row,ignore_index=True)\n",
    "    return new_data\n",
    "\n",
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "38829"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 根据权重规则对数据进行扩充\n",
    "new_data= user_power(data,add_rules,user_info)\n",
    "len(new_data)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "将测试数据集 划分为training_data与evaluate_data两部分，占比可调"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "training_data = new_data.sample(n=None, frac=0.9, replace=False, weights=None, random_state=None, axis=None)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "34946\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>db</th>\n",
       "      <th>key</th>\n",
       "      <th>size</th>\n",
       "      <th>ttl</th>\n",
       "      <th>type</th>\n",
       "      <th>value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>17638</th>\n",
       "      <td>7</td>\n",
       "      <td>3069809</td>\n",
       "      <td>301</td>\n",
       "      <td>-1</td>\n",
       "      <td>set</td>\n",
       "      <td>[497, 2572, 2576, 2584, 2591, 2722, 2724, 2732...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29182</th>\n",
       "      <td>7</td>\n",
       "      <td>306805</td>\n",
       "      <td>98</td>\n",
       "      <td>-1</td>\n",
       "      <td>set</td>\n",
       "      <td>[1512, 1539, 1540, 3461, 6440, 6446, 8892, 234...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4477</th>\n",
       "      <td>7</td>\n",
       "      <td>7063838</td>\n",
       "      <td>243</td>\n",
       "      <td>-1</td>\n",
       "      <td>set</td>\n",
       "      <td>[1056, 1064, 1073, 1177, 1178, 1574, 1576, 157...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32518</th>\n",
       "      <td>7</td>\n",
       "      <td>266481257</td>\n",
       "      <td>9</td>\n",
       "      <td>-1</td>\n",
       "      <td>set</td>\n",
       "      <td>[5852, 86272]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22614</th>\n",
       "      <td>7</td>\n",
       "      <td>333084550</td>\n",
       "      <td>12</td>\n",
       "      <td>-1</td>\n",
       "      <td>set</td>\n",
       "      <td>[1699, 2543, 6260]</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "      db        key size ttl type  \\\n",
       "17638  7    3069809  301  -1  set   \n",
       "29182  7     306805   98  -1  set   \n",
       "4477   7    7063838  243  -1  set   \n",
       "32518  7  266481257    9  -1  set   \n",
       "22614  7  333084550   12  -1  set   \n",
       "\n",
       "                                                   value  \n",
       "17638  [497, 2572, 2576, 2584, 2591, 2722, 2724, 2732...  \n",
       "29182  [1512, 1539, 1540, 3461, 6440, 6446, 8892, 234...  \n",
       "4477   [1056, 1064, 1073, 1177, 1178, 1574, 1576, 157...  \n",
       "32518                                      [5852, 86272]  \n",
       "22614                                 [1699, 2543, 6260]  "
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(len(training_data))\n",
    "training_data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 77,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "132112"
      ]
     },
     "execution_count": 77,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "int(training_data.value[0][0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "evaluate_data = new_data.drop([x for x in training_data.index])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3883\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>db</th>\n",
       "      <th>key</th>\n",
       "      <th>size</th>\n",
       "      <th>ttl</th>\n",
       "      <th>type</th>\n",
       "      <th>value</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>7</td>\n",
       "      <td>24774761</td>\n",
       "      <td>12</td>\n",
       "      <td>-1</td>\n",
       "      <td>set</td>\n",
       "      <td>[5550, 5849, 5852]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>7</td>\n",
       "      <td>37868878</td>\n",
       "      <td>1246</td>\n",
       "      <td>-1</td>\n",
       "      <td>set</td>\n",
       "      <td>[53, 110, 249, 282, 333, 334, 419, 470, 471, 5...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>7</td>\n",
       "      <td>5667082</td>\n",
       "      <td>526</td>\n",
       "      <td>-1</td>\n",
       "      <td>set</td>\n",
       "      <td>[282, 289, 290, 311, 572, 687, 713, 723, 735, ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>7</td>\n",
       "      <td>19662966</td>\n",
       "      <td>4</td>\n",
       "      <td>-1</td>\n",
       "      <td>set</td>\n",
       "      <td>[6474]</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>7</td>\n",
       "      <td>2598372</td>\n",
       "      <td>47</td>\n",
       "      <td>-1</td>\n",
       "      <td>set</td>\n",
       "      <td>[1559, 1699, 1733, 5559, 5626, 5852, 6402, 875...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   db       key  size ttl type  \\\n",
       "9   7  24774761    12  -1  set   \n",
       "14  7  37868878  1246  -1  set   \n",
       "26  7   5667082   526  -1  set   \n",
       "41  7  19662966     4  -1  set   \n",
       "50  7   2598372    47  -1  set   \n",
       "\n",
       "                                                value  \n",
       "9                                  [5550, 5849, 5852]  \n",
       "14  [53, 110, 249, 282, 333, 334, 419, 470, 471, 5...  \n",
       "26  [282, 289, 290, 311, 572, 687, 713, 723, 735, ...  \n",
       "41                                             [6474]  \n",
       "50  [1559, 1699, 1733, 5559, 5626, 5852, 6402, 875...  "
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "print(len(evaluate_data))\n",
    "evaluate_data.head()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "用training_data进行训练，导出关联规则（推荐规则）\n",
    "\n",
    "注：这里只是用置信度进行了排名，因为只是对评估函数进行测试，所以没有加入更多的排名方法。"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 161,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'generator'>\n",
      "-------------挖掘频繁项集---------------\n",
      "                     fluent_patterns   support\n",
      "0                           [102392]  0.330996\n",
      "1                           [139252]  0.305099\n",
      "2                   [102392, 139252]  0.157844\n",
      "3                     [8892, 139252]  0.166772\n",
      "4             [102392, 8892, 139252]  0.100984\n",
      "5                          [5267730]  0.300063\n",
      "6                  [102392, 5267730]  0.155268\n",
      "7                  [139252, 5267730]  0.192211\n",
      "8          [102392, 139252, 5267730]  0.106650\n",
      "9            [8892, 139252, 5267730]  0.123619\n",
      "10   [102392, 8892, 139252, 5267730]  0.075602\n",
      "11                   [8892, 5267730]  0.168918\n",
      "12           [102392, 8892, 5267730]  0.099468\n",
      "13                          [130412]  0.253133\n",
      "14                  [102392, 130412]  0.121616\n",
      "15                  [139252, 130412]  0.169748\n",
      "16          [102392, 139252, 130412]  0.089796\n",
      "17            [8892, 139252, 130412]  0.112803\n",
      "18                 [5267730, 130412]  0.155039\n",
      "19         [102392, 5267730, 130412]  0.080639\n",
      "20         [139252, 5267730, 130412]  0.123476\n",
      "21   [8892, 139252, 5267730, 130412]  0.088365\n",
      "22           [8892, 5267730, 130412]  0.105963\n",
      "23                    [8892, 130412]  0.149745\n",
      "24            [102392, 8892, 130412]  0.083929\n",
      "25                         [4312482]  0.224833\n",
      "26                 [102392, 4312482]  0.110628\n",
      "27                 [139252, 4312482]  0.139415\n",
      "28         [102392, 139252, 4312482]  0.078750\n",
      "29           [8892, 139252, 4312482]  0.090025\n",
      "..                               ...       ...\n",
      "728               [5267730, 4762714]  0.077663\n",
      "729                            [844]  0.089824\n",
      "730                           [3365]  0.081125\n",
      "731                           [1588]  0.079666\n",
      "732                          [17632]  0.075545\n",
      "733                           [6422]  0.074286\n",
      "734                          [25732]  0.070680\n",
      "735                           [5020]  0.070509\n",
      "736                           [5027]  0.079122\n",
      "737                            [184]  0.098151\n",
      "738                           [6310]  0.092915\n",
      "739                          [12872]  0.087764\n",
      "740                       [13372924]  0.090339\n",
      "741                          [11932]  0.079780\n",
      "742                           [6434]  0.152578\n",
      "743                   [102392, 6434]  0.088651\n",
      "744                     [8892, 6434]  0.090711\n",
      "745                   [139252, 6434]  0.073370\n",
      "746                  [5267730, 6434]  0.070480\n",
      "747                           [5058]  0.132032\n",
      "748                  [4762734, 5058]  0.078950\n",
      "749                           [5978]  0.108625\n",
      "750                           [5062]  0.077348\n",
      "751                           [5070]  0.085246\n",
      "752                           [5776]  0.071396\n",
      "753                         [139952]  0.070137\n",
      "754                           [1559]  0.073141\n",
      "755                           [5550]  0.094317\n",
      "756                           [5977]  0.072655\n",
      "757                         [129152]  0.076489\n",
      "\n",
      "[758 rows x 2 columns]\n",
      "                                 rules_a             rules_b  confidence\n",
      "0     (4316482, 130412, 4316382, 139252)           (5267730)    0.916201\n",
      "1    (4316482, 130412, 5267730, 4316382)            (139252)    0.915860\n",
      "2             (4762754, 4316382, 139252)           (5267730)    0.912545\n",
      "3             (4316482, 5267730, 134912)            (139252)    0.912197\n",
      "4                     (4316442, 4316382)           (5267730)    0.900451\n",
      "5             (4316482, 130412, 4316382)           (5267730)    0.899230\n",
      "6             (4316482, 130412, 4316382)            (139252)    0.898895\n",
      "7             (4316482, 4316382, 139252)           (5267730)    0.898513\n",
      "8                     (4762754, 4316382)           (5267730)    0.898070\n",
      "9              (4316482, 134912, 130412)            (139252)    0.897016\n",
      "10                   (21986963, 4316382)           (5267730)    0.896299\n",
      "11               (4316482, 130412, 8892)            (139252)    0.894666\n",
      "12              (4316482, 5267730, 8892)            (139252)    0.891374\n",
      "13                    (5267750, 4316382)           (5267730)    0.890783\n",
      "14            (4316482, 5267730, 130412)            (139252)    0.890625\n",
      "15                              (140552)            (135652)    0.888640\n",
      "16            (4312482, 4316382, 139252)           (5267730)    0.888423\n",
      "17                    (21986963, 139252)           (5267730)    0.887363\n",
      "18             (134912, 4316382, 139252)           (5267730)    0.886515\n",
      "19               (4316382, 8892, 139252)           (5267730)    0.885755\n",
      "20                   (22718131, 4316382)           (5267730)    0.884785\n",
      "21             (134932, 4316382, 139252)           (5267730)    0.883245\n",
      "22             (130412, 4316382, 139252)           (5267730)    0.878763\n",
      "23             (130412, 134912, 4316382)           (5267730)    0.878393\n",
      "24           (4316482, 5267730, 4316382)            (139252)    0.878278\n",
      "25               (130412, 8892, 4316382)           (5267730)    0.875638\n",
      "26                    (4316482, 4316382)           (5267730)    0.871769\n",
      "27                     (4316482, 134912)            (139252)    0.868074\n",
      "28                    (4312482, 4316382)           (5267730)    0.867668\n",
      "29           (4316482, 4312482, 5267730)            (139252)    0.866443\n",
      "..                                   ...                 ...         ...\n",
      "626                     (135652, 139252)              (8892)    0.611338\n",
      "627                    (4316382, 139252)   (5267730, 130412)    0.610921\n",
      "628           (4316482, 5267730, 139252)            (134912)    0.610224\n",
      "629                   (22718131, 139252)           (5267750)    0.610084\n",
      "630                    (130412, 4316382)   (4316482, 139252)    0.609950\n",
      "631                               (8792)              (8892)    0.608683\n",
      "632                              (33512)            (102392)    0.608467\n",
      "633                            (4316382)              (8892)    0.608397\n",
      "634                       (8892, 139252)           (4316382)    0.608270\n",
      "635                       (102392, 5997)            (139252)    0.606595\n",
      "636                            (4316442)           (4316382)    0.606013\n",
      "637                               (8812)              (8892)    0.605848\n",
      "638                             (102792)            (139252)    0.605821\n",
      "639                    (5267730, 139252)           (4316482)    0.605776\n",
      "640                               (8992)           (5267730)    0.605560\n",
      "641                       (8892, 139252)            (102392)    0.605525\n",
      "642                       (8792, 102252)              (8892)    0.605415\n",
      "643                      (4316382, 8892)           (4316482)    0.605323\n",
      "644                           (22503880)   (4316482, 139252)    0.604978\n",
      "645                    (4316482, 130412)  (5267730, 4316382)    0.604955\n",
      "646                               (6446)            (102392)    0.604456\n",
      "647                       (134912, 8892)   (5267730, 139252)    0.604396\n",
      "648                            (4316382)            (130412)    0.604007\n",
      "649                            (5267750)              (8892)    0.603075\n",
      "650                       (130412, 8892)            (134912)    0.602905\n",
      "651                         (8752, 8892)            (139252)    0.602655\n",
      "652                               (8812)            (102392)    0.602644\n",
      "653                       (102392, 5997)              (5800)    0.601328\n",
      "654                               (6440)            (139252)    0.600946\n",
      "655                         (8792, 8892)            (102392)    0.600699\n",
      "\n",
      "[656 rows x 3 columns]\n"
     ]
    }
   ],
   "source": [
    "\n",
    "data_list = list(training_data[\"value\"])\n",
    "frequent_itemsets = fpg.find_frequent_itemsets(data_list, minimum_support=0.07 * len(data_list), include_support=True)\n",
    "print(type(frequent_itemsets))  # print type\n",
    "result = []\n",
    "for itemset, support in frequent_itemsets:  # 将generator结果存入list\n",
    "    result.append((itemset, support / len(data_list)))\n",
    "\n",
    "result_patterns = [i[0] for i in result]\n",
    "result_support = [i[1] for i in result]\n",
    "patterns_df = pd.DataFrame({\"fluent_patterns\": result_patterns, \"support\": result_support})\n",
    "patterns = {}\n",
    "for i in result:\n",
    "    patterns[frozenset(sorted(i[0]))] = i[1]\n",
    "print(\"-------------挖掘频繁项集---------------\")\n",
    "print(patterns_df)\n",
    "\n",
    "def generate_rules(patterns, min_confidence):\n",
    "    patterns_group = group_patterns_by_length(patterns)\n",
    "    raw_rules = defaultdict(set)\n",
    "    for length, pattern_list in patterns_group.items():\n",
    "        if length == 1:\n",
    "            continue\n",
    "        for pattern, support in pattern_list:\n",
    "            item_list = list(pattern)\n",
    "            for window_size in range(1, length):\n",
    "                for i in range(0, length - window_size):\n",
    "                    for j in range(i + window_size, length):\n",
    "                        base_set = frozenset(item_list[i:j])\n",
    "                        predict_set = frozenset(pattern - base_set)\n",
    "                        confidence = support / patterns.get(base_set)\n",
    "                        if confidence > min_confidence:\n",
    "                            raw_rules[base_set].add((predict_set, confidence))\n",
    "\n",
    "                        base_set, predict_set = predict_set, base_set\n",
    "                        confidence = support / patterns.get(base_set)\n",
    "                        if confidence > min_confidence:\n",
    "                            raw_rules[base_set].add((predict_set, confidence))\n",
    "    return raw_rules\n",
    "\n",
    "def group_patterns_by_length(patterns):\n",
    "    result = defaultdict(list)\n",
    "    for pattern, support in patterns.items():\n",
    "        result[len(pattern)].append((pattern, support))\n",
    "    return result\n",
    "\n",
    "def transform(raw_rules):\n",
    "    result = list()\n",
    "    for base_set, predict_set_list in raw_rules.items():\n",
    "        for predict_set, confidence in predict_set_list:\n",
    "            result.append((base_set, predict_set, confidence))\n",
    "\n",
    "    return result\n",
    "raw_rules = generate_rules(patterns, 0.6)\n",
    "rules = transform(raw_rules)\n",
    "rules.sort(key=lambda x: x[2], reverse=True)\n",
    "rules_a = [i[0] for i in rules]\n",
    "rules_b = [i[1] for i in rules]\n",
    "confidence = [i[2] for i in rules]\n",
    "rules_df = pd.DataFrame({\"rules_a\": rules_a, \"rules_b\": rules_b, \"confidence\": confidence})\n",
    "print(rules_df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 155,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[[frozenset({'130412', '139252', '4316382', '4316482'}),\n",
       "  frozenset({'5267730'})],\n",
       " [frozenset({'130412', '4316382', '4316482', '5267730'}),\n",
       "  frozenset({'139252'})],\n",
       " [frozenset({'139252', '4316382', '4762754'}), frozenset({'5267730'})],\n",
       " [frozenset({'134912', '4316482', '5267730'}), frozenset({'139252'})],\n",
       " [frozenset({'4316382', '4316442'}), frozenset({'5267730'})]]"
      ]
     },
     "execution_count": 155,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_rules1 = []\n",
    "for a,b,c in rules:\n",
    "    new_rules1.append([a,b])\n",
    "new_rules1[:5]\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 156,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0  rules miss\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0.8515642946205972"
      ]
     },
     "execution_count": 156,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result = evaluate_association_rules(new_rules1[:100],evaluate_data)\n",
    "result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 157,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0  rules miss\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0.7758942803178905"
      ]
     },
     "execution_count": 157,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result = evaluate_association_rules(new_rules1[100:200],evaluate_data)\n",
    "result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 158,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0  rules miss\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0.7193738042259892"
      ]
     },
     "execution_count": 158,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result = evaluate_association_rules(new_rules1[200:300],evaluate_data)\n",
    "result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 159,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0  rules miss\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0.7081574353078712"
      ]
     },
     "execution_count": 159,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result = evaluate_association_rules(new_rules1,evaluate_data)\n",
    "result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 162,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "10339\n",
      "<class 'generator'>\n",
      "-------------挖掘频繁项集---------------\n",
      "                fluent_patterns   support\n",
      "0                      [102392]  0.315795\n",
      "1                        [8892]  0.269272\n",
      "2                [102392, 8892]  0.142083\n",
      "3                [139252, 8892]  0.141213\n",
      "4        [102392, 139252, 8892]  0.086952\n",
      "5               [5267730, 8892]  0.144405\n",
      "6       [102392, 5267730, 8892]  0.086179\n",
      "7       [139252, 5267730, 8892]  0.103008\n",
      "8                     [4312482]  0.205726\n",
      "9             [102392, 4312482]  0.099139\n",
      "10              [8892, 4312482]  0.103105\n",
      "11      [139252, 8892, 4312482]  0.075249\n",
      "12     [5267730, 8892, 4312482]  0.075152\n",
      "13            [139252, 4312482]  0.123803\n",
      "14           [5267730, 4312482]  0.120708\n",
      "15   [139252, 5267730, 4312482]  0.091208\n",
      "16            [130412, 4312482]  0.097011\n",
      "17    [139252, 130412, 4312482]  0.076700\n",
      "18   [5267730, 130412, 4312482]  0.072831\n",
      "19                     [135652]  0.194893\n",
      "20             [102392, 135652]  0.088306\n",
      "21               [8892, 135652]  0.088016\n",
      "22            [4312482, 135652]  0.088306\n",
      "23             [139252, 135652]  0.102911\n",
      "24            [5267730, 135652]  0.099913\n",
      "25    [139252, 5267730, 135652]  0.072638\n",
      "26             [130412, 135652]  0.084631\n",
      "27                    [4316382]  0.188510\n",
      "28            [102392, 4316382]  0.097688\n",
      "29              [8892, 4316382]  0.106780\n",
      "..                          ...       ...\n",
      "416                      [5989]  0.080569\n",
      "417                      [1539]  0.077087\n",
      "418                     [17632]  0.076410\n",
      "419                      [8812]  0.120418\n",
      "420                [8892, 8812]  0.071961\n",
      "421              [102392, 8812]  0.073218\n",
      "422                      [5069]  0.089177\n",
      "423                     [23432]  0.077957\n",
      "424                     [97912]  0.071477\n",
      "425                      [5793]  0.115001\n",
      "426                      [1733]  0.110359\n",
      "427                       [184]  0.094980\n",
      "428                      [7452]  0.128929\n",
      "429               [78552, 7452]  0.079602\n",
      "430                      [2572]  0.090047\n",
      "431                       [963]  0.082987\n",
      "432                      [5800]  0.188896\n",
      "433              [102392, 5800]  0.106297\n",
      "434              [139252, 5800]  0.085598\n",
      "435             [5267730, 5800]  0.085598\n",
      "436                [8892, 5800]  0.085501\n",
      "437                [5997, 5800]  0.107554\n",
      "438                [3450, 5800]  0.073798\n",
      "439                [3461, 5800]  0.082503\n",
      "440                      [6001]  0.096431\n",
      "441                      [2580]  0.133088\n",
      "442              [102392, 2580]  0.075056\n",
      "443                      [4188]  0.080085\n",
      "444                      [5070]  0.074765\n",
      "445                      [1650]  0.085018\n",
      "\n",
      "[446 rows x 2 columns]\n",
      "--------------频繁项集------------------\n",
      "----------------关联规则-------------------\n",
      "                         rules_a           rules_b  confidence\n",
      "0     (4316482, 4316382, 139252)         (5267730)    0.899207\n",
      "1             (5267750, 4316382)         (5267730)    0.898389\n",
      "2             (4762754, 4316382)         (5267730)    0.893303\n",
      "3        (4316382, 8892, 139252)         (5267730)    0.885057\n",
      "4     (4316482, 5267730, 130412)          (139252)    0.878021\n",
      "5             (4312482, 4316382)         (5267730)    0.872222\n",
      "6      (130412, 4316382, 139252)         (5267730)    0.872043\n",
      "7             (4316482, 4316382)         (5267730)    0.871673\n",
      "8    (4316482, 5267730, 4316382)          (139252)    0.865867\n",
      "9              (134912, 4316382)         (5267730)    0.861111\n",
      "10             (4316482, 134912)          (139252)    0.859954\n",
      "11             (4316442, 139252)         (5267730)    0.856187\n",
      "12             (4316482, 102252)          (139252)    0.855803\n",
      "13               (4316382, 8892)         (5267730)    0.854167\n",
      "14             (134932, 4316382)         (5267730)    0.853922\n",
      "15             (4316382, 139252)         (5267730)    0.852015\n",
      "16                        (1587)            (1586)    0.851810\n",
      "17             (130412, 4316382)         (5267730)    0.850442\n",
      "18    (130412, 5267730, 4316382)          (139252)    0.843913\n",
      "19             (4762754, 139252)         (5267730)    0.841991\n",
      "20            (4316482, 4316382)          (139252)    0.839354\n",
      "21             (4316482, 130412)          (139252)    0.839080\n",
      "22             (102392, 4316382)         (5267730)    0.833663\n",
      "23               (4316482, 8892)          (139252)    0.833503\n",
      "24            (4316482, 5267730)          (139252)    0.830818\n",
      "25            (4762754, 4316382)          (139252)    0.826334\n",
      "26       (130412, 5267730, 8892)          (139252)    0.825556\n",
      "27             (4316482, 102392)          (139252)    0.824462\n",
      "28            (4762754, 5267730)         (4316382)    0.823222\n",
      "29             (5267730, 102252)          (139252)    0.823171\n",
      "..                           ...               ...         ...\n",
      "229               (102392, 5997)         (5267730)    0.614686\n",
      "230           (4316482, 5267730)         (4312482)    0.613979\n",
      "231                     (139252)         (5267730)    0.613882\n",
      "232                       (8752)            (8892)    0.613048\n",
      "233               (102392, 8892)          (139252)    0.611981\n",
      "234            (102392, 5267730)            (8892)    0.611531\n",
      "235                    (4762734)         (5267730)    0.611004\n",
      "236             (102392, 102792)         (5267730)    0.609715\n",
      "237                    (5267750)         (4312482)    0.609058\n",
      "238           (5267730, 4316382)            (8892)    0.608780\n",
      "239             (134912, 130412)         (4316382)    0.608514\n",
      "240                       (8812)          (102392)    0.608032\n",
      "241             (130412, 139252)         (4316382)    0.607843\n",
      "242            (4312482, 139252)            (8892)    0.607812\n",
      "243           (4316482, 5267730)            (8892)    0.607625\n",
      "244                   (24097891)         (5267730)    0.607020\n",
      "245                     (134912)         (5267730)    0.606968\n",
      "246           (4312482, 5267730)         (5267750)    0.606571\n",
      "247               (102392, 8892)         (5267730)    0.606535\n",
      "248                   (22503880)        (22718131)    0.606184\n",
      "249           (4316482, 5267730)  (130412, 139252)    0.606037\n",
      "250            (5267730, 139252)            (8892)    0.605114\n",
      "251                       (1586)            (1587)    0.604819\n",
      "252               (8792, 102252)          (102392)    0.604459\n",
      "253                       (8772)            (6301)    0.604183\n",
      "254           (4312482, 5267730)          (130412)    0.603365\n",
      "255             (102392, 139252)            (8892)    0.603356\n",
      "256              (5267730, 8892)          (130412)    0.602813\n",
      "257                      (78352)          (102392)    0.602158\n",
      "258                    (4312482)          (139252)    0.601787\n",
      "\n",
      "[259 rows x 3 columns]\n",
      "----------------关联规则-------------------\n",
      "{130412, 4316482, 139252, 4316382} 5267730 0.9162011173184358 5.4790212506303915\n",
      "{4316482, 5267730, 130412, 4316382} 139252 0.9158600148920326 5.334894555722442\n",
      "{4762754, 139252, 4316382} 5267730 0.9125448028673835 5.477193093404866\n",
      "{134912, 4316482, 5267730} 139252 0.9121969140337988 5.333063005293325\n",
      "{4316442, 4316382} 5267730 0.9004510309278351 5.471146207435091\n",
      "{4316482, 130412, 4316382} 5267730 0.8992299966521594 5.470535690297254\n",
      "{4316482, 130412, 4316382} 139252 0.8988952125878807 5.326412154570366\n",
      "{4316482, 139252, 4316382} 5267730 0.8985126859142608 5.470177034928304\n",
      "{4762754, 4316382} 5267730 0.8980699638118215 5.4699556738770845\n",
      "{134912, 4316482, 130412} 139252 0.8970160116448326 5.325472554098842\n",
      "{21986963, 4316382} 5267730 0.8962988826815642 5.4690701333119565\n",
      "{130412, 4316482, 8892} 139252 0.8946657663740717 5.324297431463461\n",
      "{4316482, 5267730, 8892} 139252 0.8913738019169328 5.3226514492348915\n",
      "{5267750, 4316382} 5267730 0.8907828282828283 5.466312106112588\n",
      "{4316482, 5267730, 130412} 139252 0.890625 5.322277048276425\n",
      "{140552} 135652 0.88864 5.4950170538583025\n",
      "{4312482, 139252, 4316382} 5267730 0.8884225253585171 5.465131954650433\n",
      "{21986963, 139252} 5267730 0.8873626373626373 5.464602010652492\n",
      "{134912, 139252, 4316382} 5267730 0.8865153538050735 5.464178368873711\n",
      "{8892, 139252, 4316382} 5267730 0.8857545839210155 5.4637979839316815\n",
      "{22718131, 4316382} 5267730 0.8847848187055236 5.463313101323935\n",
      "{139252, 134932, 4316382} 5267730 0.883245382585752 5.46254338326405\n",
      "{130412, 139252, 4316382} 5267730 0.8787629994526547 5.460302191697501\n",
      "{134912, 130412, 4316382} 5267730 0.8783926683115968 5.460117026126972\n",
      "{4316482, 5267730, 4316382} 139252 0.8782782212086659 5.316103658880758\n",
      "{130412, 8892, 4316382} 5267730 0.8756377551020408 5.458739569522194\n",
      "{4316482, 4316382} 5267730 0.8717693836978131 5.456805383820081\n",
      "{134912, 4316482} 139252 0.8680738786279684 5.311001487590409\n",
      "{4312482, 4316382} 5267730 0.8676683039583936 5.45475484395037\n",
      "{4312482, 5267730, 4316482} 139252 0.8664429530201342 5.310186024786493\n",
      "{130412, 8892, 4316382} 139252 0.8644770408163264 5.309203068684589\n",
      "{4316482, 102252} 139252 0.8639975550122249 5.308963325782537\n",
      "{4762754, 5267730, 139252} 4316382 0.8636363636363635 4.864775641837423\n",
      "{134912, 4316382} 5267730 0.8634349030470914 5.4526381434947195\n",
      "{1587} 1586 0.8623253047873922 5.304423648236786\n",
      "{102392, 139252, 4316382} 5267730 0.8618243243243244 5.451832854133336\n",
      "{8932, 4316382} 5267730 0.8612716763005781 5.451556530121463\n",
      "{22503880, 5267730} 139252 0.8602986932171749 5.3071138948850125\n",
      "{4312482, 5267730, 130412} 139252 0.8598035895699289 5.306866343061389\n",
      "{22503880, 130412} 139252 0.8595394736842106 5.30673428511853\n",
      "{130412, 4316382} 5267730 0.8577919127669242 5.449816648354636\n",
      "{4316442, 139252} 5267730 0.8564413633737724 5.44914137365806\n",
      "{8892, 4316382} 5267730 0.8556608028867839 5.4487510934145655\n",
      "{4316482, 134932} 139252 0.8554179566563469 5.304673526604598\n",
      "{4316482, 5267750} 139252 0.8551007147498376 5.304514905651344\n",
      "{4762754, 5267730, 4316382} 139252 0.8549361987911349 5.304432647671993\n",
      "{139252, 4316382} 5267730 0.8529299847792998 5.447385684360824\n",
      "{8792, 4316482} 139252 0.8524378430739425 5.303183469813397\n",
      "{4316482, 4316382} 139252 0.8521371769383698 5.3030331367456105\n",
      "{134912, 5267730, 4316382} 139252 0.8521013795316009 5.303015238042225\n",
      "{134932, 4316382} 5267730 0.851528384279476 5.446684884110912\n",
      "{102252, 4316382} 139252 0.8514492753623188 5.302689185957584\n",
      "{5267730, 130412, 4316382} 139252 0.8503707627118645 5.302149929632358\n",
      "{4316482, 130412} 139252 0.8497747747747749 5.301851935663812\n",
      "{4316482, 8892} 139252 0.8472782258064516 5.300603661179651\n",
      "{8792, 4316382} 5267730 0.846774193548387 5.444307788745368\n",
      "{102252, 134932} 139252 0.8458471760797341 5.299888136316293\n",
      "{4312482, 5267730, 4316382} 139252 0.8458208458208458 5.299874971186848\n",
      "{4316482, 5267730} 139252 0.845067497403946 5.299498296978398\n",
      "{134912, 5267730, 130412} 139252 0.8445404071560765 5.299234751854463\n",
      "{4762754, 139252} 5267730 0.8442153493699885 5.4430283666561685\n",
      "{22718131, 4316382} 139252 0.8434429007116232 5.298685998632237\n",
      "{102252, 4316382} 5267730 0.8432147562582345 5.442528070100291\n",
      "{4312482, 102252} 139252 0.8424098025867938 5.298169449569822\n",
      "{134912, 5267730, 8892} 139252 0.8424098025867938 5.298169449569822\n",
      "{102392, 4316482} 139252 0.8416616496086695 5.29779537308076\n",
      "{4316482, 4762734} 139252 0.841455044612217 5.297692070582534\n",
      "{4762754, 4316382} 139252 0.8413751507840771 5.297652123668464\n",
      "{4762754, 130412} 139252 0.8404255319148936 5.297177314233872\n",
      "{134912, 4316482, 139252} 5267730 0.8385680513340088 5.440204717638179\n",
      "{4762754, 5267730} 4316382 0.838164931044188 4.852039925541336\n",
      "{130412, 4316482, 8892} 5267730 0.8379473328831871 5.439894358412768\n",
      "{8792, 4316382} 139252 0.8346774193548386 5.294303257953844\n",
      "{5267730, 102252} 139252 0.8344283837056504 5.294178740129251\n",
      "{4316442, 8892} 5267730 0.8341625207296849 5.438001952336016\n",
      "{22718131, 130412} 139252 0.8341094295692667 5.294019263061059\n",
      "{130412, 5267730, 8892} 139252 0.8339184445044558 5.293923770528653\n",
      "{130412, 8932} 139252 0.8337137267688296 5.29382141166084\n",
      "{102392, 4316382} 5267730 0.833552804845931 5.43769709439414\n",
      "{22503880, 130412} 4316482 0.8328947368421052 4.139821363229454\n",
      "{134912, 4316482, 139252} 130412 0.8324890239783858 4.745858409500493\n",
      "{4312482, 5267730, 8892} 139252 0.8321451717433572 5.293037134148104\n",
      "{5267750, 4316382} 139252 0.8311237373737375 5.292526416963294\n",
      "{134912, 8892, 139252} 130412 0.8302439024390245 4.744735848730812\n",
      "{130412, 4316382} 139252 0.830077237619264 5.292003167086057\n",
      "{134912, 4316382} 139252 0.8299168975069251 5.2919229970298876\n",
      "{4316482, 8892, 139252} 5267730 0.8298631766805472 5.4358522803114475\n",
      "{4762754, 5267730} 139252 0.8297213622291022 5.291825229390977\n",
      "{130412, 102252} 139252 0.8296431362333941 5.291786116393122\n",
      "{4316482, 5267750} 5267730 0.8291098115659519 5.43547559775415\n",
      "{130412, 4762734} 139252 0.8281148075668623 5.2910219520598565\n",
      "{5267730, 8892, 4316382} 139252 0.8276225619399051 5.290775829246378\n",
      "{4312482, 4316382} 139252 0.8260618318405085 5.2899954641966795\n",
      "{78352, 130412} 139252 0.8259408602150538 5.289934978383952\n",
      "{4762754, 130412} 5267730 0.821964956195244 5.431903170068796\n",
      "{130412, 5267750} 139252 0.8203469567774184 5.287138026665135\n",
      "{4312482, 8892, 139252} 5267730 0.8162746344564528 5.429058009199401\n",
      "{130412, 4316482, 139252} 5267730 0.8157964484495097 5.428818916195929\n",
      "{8892, 139252, 134932} 5267730 0.8152313624678663 5.428536373205107\n",
      "{130412, 4312482, 139252} 5267730 0.8117007672634271 5.426771075602888\n",
      "{4312482, 139252, 4316482} 5267730 0.8106750392464679 5.426258211594408\n",
      "{8932, 4316382} 139252 0.8105330764290302 5.28223108649094\n",
      "{5267730, 21986963} 139252 0.8100313479623824 5.281980222257617\n",
      "{139252, 8932} 5267730 0.8100056211354694 5.425923502538908\n",
      "{134912, 8892, 130412} 139252 0.80919175911252 5.2815604278326855\n",
      "{8792, 5267730} 139252 0.8085683297180044 5.281248713135428\n",
      "{5267730, 134932, 4316382} 139252 0.807843137254902 5.2808861169038765\n",
      "{130412, 8932} 8892 0.807303553961526 5.359790043422339\n",
      "{5997, 4316382} 5267730 0.8061254831995243 5.423983433570936\n",
      "{102392, 5267730, 4316382} 139252 0.806003159557662 5.279966128055256\n",
      "{134912, 4316482} 130412 0.8056288478452067 4.732428321433903\n",
      "{78352, 5267730} 139252 0.8055555555555555 5.279742326054203\n",
      "{130412, 8932} 5267730 0.805021193348549 5.423431288645449\n",
      "{134912, 8892, 139252} 5267730 0.8048780487804877 5.423359716361418\n",
      "{5267730, 21986963} 4316382 0.8047021943573667 4.835308557197925\n",
      "{4312482, 130412} 139252 0.8045267489711935 5.279227922762022\n",
      "{5267730, 22718131} 139252 0.8032827654812236 5.278605931017037\n",
      "{4316382} 5267730 0.8029637760702526 5.422402580006301\n",
      "{4316482, 134932} 5267730 0.8012383900928793 5.421539887017613\n",
      "{22503880, 4316482} 139252 0.8010891372886215 5.277509116920736\n",
      "{8792, 130412} 139252 0.8008253094910592 5.277377203021955\n",
      "{8752, 139252} 8892 0.8007907542579076 5.356533643570529\n",
      "{22503880, 5267730} 4316482 0.8002489110143125 4.123498450315557\n",
      "{134912, 5267730} 139252 0.7998610145934677 5.276895055573159\n",
      "{8892, 4316382} 139252 0.7995038340099233 5.276716465281387\n",
      "{134912, 5267730, 4316382} 130412 0.7994866859159447 4.729357240469272\n",
      "{130412, 4316482, 5267730, 139252} 4316382 0.7992202729044833 4.832567596471483\n",
      "{4762754, 139252} 4316382 0.7989690721649484 4.832441996101716\n",
      "{5267730, 8892, 134932} 139252 0.7985520931696568 5.276240594861253\n",
      "{4316482, 5267730, 139252, 4316382} 130412 0.798442064264849 4.728834929643725\n",
      "{134912, 4316482} 5267730 0.7980064497214893 5.419923916831919\n",
      "{24069719} 5267730 0.7972578763127188 5.419549630127533\n",
      "{22503880, 139252} 4316482 0.7969774736241803 4.121862731620491\n",
      "{22718131, 5267750} 139252 0.7968015051740358 5.275365300863443\n",
      "{5267730, 130412} 139252 0.7964193429309708 5.275174219741911\n",
      "{21986963} 5267730 0.7963055416874688 5.419073462814908\n",
      "{130412, 5267750} 5267730 0.7953543075566011 5.418597845749474\n",
      "{4312482, 4316482} 139252 0.7938683948155533 5.2738987456842015\n",
      "{4316442, 4316382} 139252 0.7934922680412371 5.273710682297044\n",
      "{4316482, 5267730, 8892} 130412 0.7929712460063898 4.726099520514495\n",
      "{134912, 5267730, 139252} 130412 0.7929336808572257 4.726080737939913\n",
      "{24097891, 139252} 5267730 0.7908557306147668 5.416348557278558\n",
      "{4316482, 8892} 5267730 0.7888104838709677 5.415325933906658\n",
      "{22503880, 139252} 5267730 0.7884231536926148 5.415132268817481\n",
      "{4316482, 8892, 139252} 130412 0.7882212968471148 4.723724545934857\n",
      "{4316482, 22718131} 139252 0.787574606619642 5.270751851586247\n",
      "{130412, 134932} 139252 0.7874197689345314 5.270674432743691\n",
      "{4762754, 130412} 4316382 0.7866082603254066 4.826261590181945\n",
      "{139252, 5267750} 5267730 0.7860465116279071 5.413943947785127\n",
      "{134912, 4316382} 130412 0.7858725761772852 4.7225501855999426\n",
      "{8752, 5267730} 8892 0.7849756690997568 5.348626100991454\n",
      "{22718131, 5267750} 4312482 0.7845719661335843 5.258371771518206\n",
      "{22718131, 130412} 5267730 0.7837601862630967 5.412800785102722\n",
      "{130412, 8892, 139252} 5267730 0.7833587011669204 5.412600042554634\n",
      "{5267730, 4762734} 139252 0.7831775700934579 5.268553333323154\n",
      "{4316482, 139252, 4316382} 130412 0.7830271216097988 4.721127458316199\n",
      "{22718131, 8892} 139252 0.7815005727376861 5.267714834645268\n",
      "{5267730, 8932} 139252 0.7808182064481171 5.267373651500484\n",
      "{102392, 4316382} 139252 0.7795628127469054 5.266745954649878\n",
      "{22718131, 5267750} 5267730 0.7795547193477579 5.410698051645053\n",
      "{134932, 4316382} 139252 0.7788338042640637 5.266381450408457\n",
      "{4316482, 130412} 5267730 0.7783783783783784 5.410109881160363\n",
      "{134912, 139252, 130412} 5267730 0.778283115406481 5.410062249674414\n",
      "{4316482, 5267730, 130412} 4316382 0.7771990740740741 4.821556997056279\n",
      "{5800, 6446} 5997 0.7768724537762457 4.973930608706635\n",
      "{22718131, 139252} 5267730 0.7755102040816326 5.40867579401199\n",
      "{139252, 8932} 8892 0.7754356379988758 5.343856085441013\n",
      "{4312482, 5267730} 139252 0.7711073398387781 5.262518218195814\n",
      "{5267750, 4762734} 4312482 0.7709444618763728 5.2515580193896\n",
      "{134912, 8892} 130412 0.7704517704517704 4.714839782737185\n",
      "{139252, 134932} 5267730 0.770046669495121 5.405944026718735\n",
      "{8892, 102252} 139252 0.7693298969072164 5.261629496730033\n",
      "{4762754, 139252} 130412 0.7691867124856816 4.714207253754141\n",
      "{134912, 5267730, 139252} 4316382 0.7691862148856068 4.817550567462045\n",
      "{134912, 5267730, 130412} 4316382 0.7686613201727328 4.817288120105608\n",
      "{4762754, 4316382} 5267730 0.7677925211097707 5.404816952526059\n",
      "{4762754, 4316382} 139252 0.7677925211097707 5.2608608088313105\n",
      "{22718131, 8892} 5267730 0.7671821305841924 5.40451175726327\n",
      "{4316442} 5267730 0.7668879344006249 5.4043646591714865\n",
      "{8892, 4762734} 139252 0.7668409720086128 5.2603850342807315\n",
      "{130412, 5267730, 139252, 4316382} 4316482 0.7661164746184989 4.10643223211765\n",
      "{5267730, 4316382} 139252 0.7660628844839371 5.2599959905183935\n",
      "{4316482, 5267730, 4316382} 130412 0.765678449258837 4.712453122140719\n",
      "{8892, 139252, 4316382} 130412 0.7647390691114245 4.711983432067012\n",
      "{8892, 5267750} 5267730 0.7635275754422477 5.402684479692298\n",
      "{4762754} 5267730 0.7631013745704467 5.402471379256397\n",
      "{134912, 139252} 130412 0.7626273574680252 4.710927576245313\n",
      "{4316462} 5267730 0.7625542467451952 5.402197815343771\n",
      "{134912, 130412} 139252 0.7619666450075807 5.257947870780216\n",
      "{8892, 4762734} 5267730 0.7616118117502307 5.401726597846289\n",
      "{11712, 139252} 5267730 0.7611982082866741 5.401519796114511\n",
      "{139252, 4762734} 5267730 0.7608300907911802 5.4013357373667645\n",
      "{102392, 5267730, 8892} 139252 0.7600690448791715 5.256999070716011\n",
      "{5267730, 134932} 139252 0.7597321054834659 5.256830601018158\n",
      "{4312482, 130412} 5267730 0.7595164609053497 5.4006789224238485\n",
      "{22503880} 139252 0.7590909090909091 5.25651000282188\n",
      "{4316482, 139252} 5267730 0.7590001865323633 5.400420785237356\n",
      "{78552, 5267730} 139252 0.7581475128644941 5.256038304708673\n",
      "{4762754, 4316382} 130412 0.758142340168878 4.708685067595739\n",
      "{8892, 134932} 5267730 0.7576913904125924 5.39976638717747\n",
      "{4316482, 5267730, 139252} 4316382 0.7571884984025559 4.811551709220519\n",
      "{102392, 102252} 139252 0.7569301848049281 5.255429640678889\n",
      "{4316482, 5267730, 139252} 130412 0.7564512165151143 4.707839505768857\n",
      "{102792, 8892} 102392 0.755457308648798 5.405506432102176\n",
      "{22503880} 4316482 0.7551948051948052 4.100971397405804\n",
      "{102392, 134932} 5267730 0.7551585304479115 5.3984999571951295\n",
      "{4316442, 5267730} 139252 0.754837067209776 5.254383081881313\n",
      "{134932, 5997} 5267730 0.7547667937811675 5.3983040888617575\n",
      "{8792, 102392} 102252 0.7541869259859535 5.183553917893229\n",
      "{130412, 8892} 139252 0.7532963883049875 5.253612742428919\n",
      "{8792, 139252} 102252 0.7519135524538496 5.182417231127177\n",
      "{4312482, 8892} 139252 0.7511938872970392 5.252561491924945\n",
      "{134912, 5267730} 130412 0.7509844799629373 4.705106137492769\n",
      "{130412, 134932} 5267730 0.7509627727856225 5.396402078363986\n",
      "{134912, 8892} 139252 0.7509157509157509 5.2524224237343\n",
      "{5267730, 8932} 8892 0.750474126253048 5.3313753295680995\n",
      "{4762754} 139252 0.75 5.251964548276425\n",
      "{102392, 134932} 139252 0.7498741821841973 5.251901639368524\n",
      "{8792, 130412} 102252 0.749656121045392 5.181288515422948\n",
      "{102392, 8892, 139252} 5267730 0.7486540096344573 5.395247696788402\n",
      "{134912, 139252} 5267730 0.748536743984392 5.39518906396337\n",
      "{102792, 5267730} 139252 0.7467105263157895 5.25031981143432\n",
      "{4316482, 8892} 130412 0.7464717741935483 4.702849784608074\n",
      "{5267730, 5267750} 139252 0.7463970246397026 5.250163060596276\n",
      "{4316482} 139252 0.7463455380760129 5.250137317314431\n",
      "{4312482, 139252} 5267730 0.7461001642036125 5.39397077407298\n",
      "{102392, 4316482} 5267730 0.7456351595424443 5.3937382717423965\n",
      "{22503880, 139252} 130412 0.7450812660393499 4.702154530530975\n",
      "{135652, 130412} 139252 0.7442462600690449 5.249087678310948\n",
      "{130412, 5267730, 139252} 4316382 0.7441483198146003 4.805031619926542\n",
      "{8792, 102392} 139252 0.7433819556996217 5.248655526126236\n",
      "{4312482, 4316482} 5267730 0.7427716849451645 5.392306534443756\n",
      "{4316482, 4316382} 130412 0.7422962226640158 4.700762008843308\n",
      "{8892, 134932} 139252 0.7421893632244215 5.248059229888636\n",
      "{130412, 139252, 4316382} 8892 0.7419266557197591 5.327101594301455\n",
      "{130412, 5267730, 8892} 4316382 0.7415608965703484 4.803737908304416\n",
      "{78352, 5267730} 8892 0.7414089347079037 5.3268427337955275\n",
      "{8892, 139252} 5267730 0.7412491420727523 5.39154526300755\n",
      "{4312482, 5267750} 5267730 0.7405554165624217 5.391198400252385\n",
      "{4762754, 5267730} 130412 0.7393751759076836 4.699301485465142\n",
      "{102392, 130412} 139252 0.7383529411764705 5.246141018864661\n",
      "{5267730, 135652} 139252 0.7380309354284311 5.245980015990641\n",
      "{5267730, 139252, 134932} 4316382 0.737741046831956 4.80182798343522\n",
      "{78352, 8892} 139252 0.7372415598010992 5.245585328176975\n",
      "{22503880, 4316482} 5267730 0.7371739753511035 5.389507679646726\n",
      "{4312482, 8892} 5267730 0.7368672397325692 5.389354311837459\n",
      "{134912, 4316382} 5267730 0.7357340720221607 5.388787727982255\n",
      "{134912, 4316382} 139252 0.7357340720221607 5.244831584287506\n",
      "{4316482, 22718131} 5267730 0.7352143244709712 5.38852785420666\n",
      "{130412, 139252, 4316382} 4316482 0.7348111658456485 4.090779577731226\n",
      "{8792, 130412} 8892 0.7348005502063274 5.323538541544739\n",
      "{8892, 5267750} 139252 0.7346514047866806 5.244290250669765\n",
      "{8892, 8932} 5267730 0.7345531689207107 5.388197276431529\n",
      "{5997, 4316382} 139252 0.7344632768361582 5.244196186694504\n",
      "{102792, 139252} 102392 0.7339204697091006 5.394738012632327\n",
      "{4312482, 4762734} 139252 0.7337931034482759 5.243861100000563\n",
      "{78352, 139252} 8892 0.7334027596979954 5.322839646290573\n",
      "{4312482, 22718131} 139252 0.7331319234642498 5.24353051000855\n",
      "{78352, 139252} 5267730 0.7323613642280656 5.387101374085207\n",
      "{8892, 102252} 8792 0.731958762886598 5.321377918356293\n",
      "{130412, 5267750} 8892 0.7318435754189945 5.3220600541510725\n",
      "{5267730, 8892} 139252 0.7318312722344571 5.242880184393654\n",
      "{8892, 8932} 139252 0.7316361707769823 5.242782633664916\n",
      "{4312482, 5267750} 139252 0.7290467850888166 5.241487940820834\n",
      "{4316482, 5267730} 4316382 0.7285565939771548 4.797235757007819\n",
      "{130412, 139252} 5267730 0.7274106540795684 5.384626019010958\n",
      "{5267730, 130412, 4316382} 8892 0.7272245762711865 5.319750554577169\n",
      "{102792, 139252} 5267730 0.7269815852682144 5.384411484605281\n",
      "{21986963} 139252 0.72690963554668 5.240419366049765\n",
      "{5267730, 8892, 139252} 4316382 0.7268518518518517 4.796383385945167\n",
      "{5267730, 8932} 4316382 0.7266323489569223 4.796273634497703\n",
      "{102792, 5267730} 102392 0.7258771929824562 5.3907163742690045\n",
      "{22503880, 4316482} 130412 0.7257093723129837 4.692468583667792\n",
      "{134912, 139252, 130412} 8892 0.7256964184195566 5.318986475651354\n",
      "{22718131, 130412} 4316482 0.7246798603026775 4.08571392495974\n",
      "{8752, 102392} 8892 0.7242603550295859 5.318268443956368\n",
      "{5267730, 24097891} 139252 0.7237772123268306 5.23885315443984\n",
      "{5267730, 8892, 4316382} 130412 0.7237743806009489 4.691501087811774\n",
      "{11712, 5267730} 139252 0.7237157306361459 5.238822413594498\n",
      "{134912, 4316482} 130412 0.722661975960129 4.690944885491365\n",
      "{134912, 4316482} 139252 0.722661975960129 5.23829553625649\n",
      "{134932, 5997} 139252 0.7224992666471106 5.2382141815999805\n",
      "{135652, 139252} 5267730 0.7220754263752102 5.381958405158779\n",
      "{134912, 5267730} 4316382 0.7220291869353719 4.793972053486927\n",
      "{102392, 134912} 139252 0.7211948790896159 5.237561987821233\n",
      "{4316382} 139252 0.7211855104281011 5.237557303490476\n",
      "{4312482, 4316382} 4316482 0.7203120485408842 4.083530019078843\n",
      "{139252, 5997} 5267730 0.7195396547410557 5.380690519341702\n",
      "{134912, 5267730, 139252} 4316482 0.719084853750362 4.082916421683582\n",
      "{139252, 8932} 130412 0.7186621697582912 4.688944982390446\n",
      "{4316482, 5267730, 130412} 8892 0.7181712962962964 5.3152239145897235\n",
      "{4316482, 5267730} 130412 0.7177570093457945 4.688492402184197\n",
      "{134912, 8892} 5267730 0.7174603174603175 5.379650850701332\n",
      "{134912, 5267730, 139252} 8892 0.7167680278019114 5.314522280342532\n",
      "{102392, 102252} 8792 0.7166324435318275 5.313714758678908\n",
      "{4762754, 5267730} 4316382 0.7165775401069518 4.791246230072717\n",
      "{4762754, 5267730} 139252 0.7165775401069518 5.235253318329901\n",
      "{5267730, 139252, 4316382} 130412 0.7162614320767343 4.687744613549667\n",
      "{8792, 5267730} 8892 0.7158351409978307 5.314055836940491\n",
      "{8772} 8892 0.7157831082443056 5.314029820563729\n",
      "{130412, 5267730, 139252} 8892 0.7156431054461182 5.3139598191646344\n",
      "{102392, 78352} 8892 0.7156330380108603 5.313954785447006\n",
      "{21986963} 4316382 0.7149276085871193 4.790421264312801\n",
      "{5267730, 8892, 139252} 130412 0.7148148148148148 4.687021304918708\n",
      "{8792, 5267730} 102252 0.7147505422993492 5.163835726049927\n",
      "{5267730, 3461} 139252 0.7146822092700528 5.234305652911452\n",
      "{4316482, 22718131} 4312482 0.713781877373847 5.222976727138338\n",
      "{139252, 5267750} 4312482 0.7133414932680539 5.222756535085441\n",
      "{130412, 5267730, 139252} 4316482 0.7133256083429896 4.080036798979896\n",
      "{130412, 4316382} 8892 0.7124034529759201 5.312339992929536\n",
      "{4762754} 4316382 0.7121993127147767 4.78905711637663\n",
      "{8792, 102252} 139252 0.7120017053933064 5.232965400973079\n",
      "{102392, 4312482} 139252 0.7118468701500258 5.232887983351438\n",
      "{4316482, 5267730, 130412} 4316382 0.7118055555555555 4.788860237797019\n",
      "{4316482, 5267730, 130412} 139252 0.7118055555555555 5.232867326054203\n",
      "{130412, 4316482, 139252} 4316382 0.7116353034720381 4.78877511175526\n",
      "{4316442, 5267730} 4316382 0.7115580448065174 4.7887364824225\n",
      "{4316442, 139252} 4316382 0.7114384748700173 4.7886766974542505\n",
      "{5267730, 130412, 4316382} 4316482 0.7113347457627119 4.079041367689757\n",
      "{102392, 78352} 139252 0.7107745070020006 5.232351801777425\n",
      "{4312482, 5267730, 139252} 4316482 0.7103163686382393 4.078532179127521\n",
      "{130412, 102252} 8792 0.7098202656941912 5.31030866976009\n",
      "{139252, 8932} 4316382 0.7093872962338392 4.787651108136161\n",
      "{102392, 5267730, 139252} 8892 0.7088811376442179 5.3105788352636845\n",
      "{4312482, 22718131} 5267730 0.7079556898288016 5.374898536885575\n",
      "{130412, 8892} 5267730 0.7076246894706669 5.374733036706507\n",
      "{4312482, 4762734} 5267730 0.7075862068965516 5.37471379541945\n",
      "{135652, 8892} 5267730 0.707534431541993 5.37468790774217\n",
      "{78552, 8892} 139252 0.7073784237003912 5.2306537601266205\n",
      "{8892, 4316382} 130412 0.7072620658547587 4.683244930438679\n",
      "{78552, 5267730} 8892 0.7069754145225843 5.309625973702868\n",
      "{4312482, 5267730, 139252} 8892 0.7064649243466301 5.309370728614891\n",
      "{4316482, 139252} 130412 0.7037866069763103 4.681507200999455\n",
      "{130412, 4316482, 139252} 8892 0.7023588656241717 5.3073176992536615\n",
      "{134912, 130412} 5267730 0.7021875676846437 5.372014475813496\n",
      "{5267730, 5997} 139252 0.7021484375 5.228038767026425\n",
      "{4316482, 5267730, 4316382} 130412 0.7012542759407069 4.680241035481654\n",
      "{4316482, 5267730, 4316382} 139252 0.7012542759407069 5.227591686246779\n",
      "{78552, 139252} 5267730 0.701216287678477 5.3715288358104125\n",
      "{134912, 139252, 130412} 4316482 0.7006822057987493 4.073715097707776\n",
      "{5267730, 139252, 4316382} 8892 0.7004238233325897 5.306350178107871\n",
      "{134912, 4316382} 8892 0.7000000000000001 5.306138266441575\n",
      "{102252, 139252} 8792 0.6996229576874738 5.305210015756732\n",
      "{5267730, 22718131} 4312482 0.699328525242477 5.215750051072653\n",
      "{22718131, 139252} 4312482 0.6991596638655463 5.215665620384187\n",
      "{5267730, 139252, 134932} 8892 0.6988980716253443 5.3055873022542475\n",
      "{4312482, 5267730, 139252} 4316382 0.6987620357634113 4.7823384779009475\n",
      "{4312482, 5267730, 139252} 130412 0.6984869325997249 4.678857363811162\n",
      "{8932} 8892 0.697171381031614 5.304723956957383\n",
      "{22718131, 139252} 4316482 0.6969987995198079 4.071873394568305\n",
      "{5267730, 130412} 4316382 0.696936138796604 4.781425529417543\n",
      "{8792, 102392} 8892 0.6961102106969206 5.304193371790036\n",
      "{22503880} 5267730 0.6956709956709958 5.368756189806672\n",
      "{139252, 4316382} 130412 0.6952054794520547 4.677216637237327\n",
      "{5267730, 134932} 4316382 0.6938049393051486 4.779859929671816\n",
      "{102392, 4316382} 8892 0.6931788253884646 5.302727679135808\n",
      "{8792, 8892} 139252 0.6927738927738928 5.223351494663372\n",
      "{5267730, 102252} 8792 0.6927726675427068 5.301784870684348\n",
      "{11712, 139252} 8892 0.6923292273236281 5.302302880103389\n",
      "{130412, 102252} 8892 0.6915863506121386 5.301931441747645\n",
      "{130412, 134932} 8892 0.6913992297817715 5.301837881332461\n",
      "{139252, 5267750} 8892 0.6913096695226438 5.301793101202898\n",
      "{78552, 8892} 5267730 0.6911682504192286 5.366504817180788\n",
      "{102392, 130412} 8892 0.6901176470588235 5.301197089970987\n",
      "{139252, 4762734} 4312482 0.6900129701686122 5.21109227353572\n",
      "{5267730, 102252} 130412 0.6896189224704337 4.674423358746517\n",
      "{22718131, 139252} 130412 0.6881152460984394 4.67367152056052\n",
      "{5267730, 5267750} 4312482 0.6880520688052069 5.210111822854018\n",
      "{130412, 8892, 139252} 4316382 0.6877219685438863 4.776818444291185\n",
      "{135652, 8892} 139252 0.6872805833108291 5.220604839931839\n",
      "{5267730, 139252, 4316382} 4316482 0.6872629935311175 4.06700549157396\n",
      "{102392, 5267730} 139252 0.6868779948396609 5.220403545696255\n",
      "{4762754} 130412 0.686426116838488 4.672826955930544\n",
      "{4316482, 5267730, 139252} 8892 0.6856721553207176 5.298974344101935\n",
      "{102392, 134932} 8892 0.6854554604932058 5.298865996688178\n",
      "{102252} 139252 0.6854271356783919 5.219678116115621\n",
      "{5267730, 4762734} 4312482 0.6849132176234979 5.208542397263163\n",
      "{102792, 8892} 139252 0.6847195357833656 5.219324316168108\n",
      "{102392, 5267730, 139252} 4316382 0.6844647169305071 4.7751898184844945\n",
      "{8892, 102252} 130412 0.6842783505154638 4.671753072769032\n",
      "{21986963} 4316482 0.6839740389415877 4.065361014279195\n",
      "{130412, 102252} 5267730 0.6835113310758011 5.362676357509074\n",
      "{5267730, 130412} 8892 0.6834625322997416 5.297869532591447\n",
      "{134912, 130412} 8892 0.6833441628763266 5.297810347879739\n",
      "{5267730, 3461} 8892 0.6833194560088814 5.297797994446016\n",
      "{8792, 5267730} 4316382 0.6832971800433839 4.7746060500409335\n",
      "{139252, 5267750} 130412 0.6829865361077111 4.6711071655651555\n",
      "{11712, 5267730} 8892 0.6824594091030077 5.297367970993079\n",
      "{8932} 5267730 0.6823812164910334 5.362111300216691\n",
      "{5267730, 5267750} 8892 0.6822408182240819 5.297258675553617\n",
      "{134912, 5267730} 8892 0.6805652073198981 5.2964208701015245\n",
      "{4312482, 130412} 4316482 0.6802983539094651 4.0635231717631335\n",
      "{139252, 3461} 5267730 0.6799577501980459 5.360899567070197\n",
      "{134932} 5267730 0.6785967902286607 5.360219087085504\n",
      "{130412, 4316382} 4316482 0.678555202180827 4.0626515958988145\n",
      "{8792, 130412} 5267730 0.678404401650619 5.3601228927964835\n",
      "{134932, 4316382} 8892 0.6781402517338813 5.295208392308516\n",
      "{4312482, 4762734} 5267750 0.6777931034482758 5.294526079125252\n",
      "{78352, 8892} 5267730 0.6775713164093169 5.359706350175832\n",
      "{6001} 8892 0.6775436793422406 5.294910106112696\n",
      "{4312482, 130412} 8892 0.6772119341563786 5.294744233519765\n",
      "{4316482, 8892} 4316382 0.6764112903225806 4.771163105180531\n",
      "{8892, 139252} 130412 0.6763898421413864 4.667808818581993\n",
      "{4316442} 139252 0.6759078484966811 5.214918472524766\n",
      "{102392, 139252} 5267730 0.675670775924583 5.358756079933466\n",
      "{4316482, 22718131} 130412 0.6755290287574607 4.667378411890031\n",
      "{102792} 102392 0.6750202101859337 5.365287882870744\n",
      "{5267750} 5267730 0.6749294006903044 5.358385392316326\n",
      "{5267730, 102252} 8892 0.6749014454664914 5.293588989174822\n",
      "{139252, 4316382} 8892 0.6744672754946727 5.293371904188912\n",
      "{8892, 5267750} 4312482 0.6740374609781477 5.2031045189404885\n",
      "{5267730, 22718131} 4316482 0.6739617010693858 4.060354845343094\n",
      "{102252} 8792 0.6735104091888011 5.292153741507395\n",
      "{6001} 139252 0.6734326824254881 5.2136808894891695\n",
      "{130412, 139252, 4316382} 4316482 0.6732348111658456 4.059991400391324\n",
      "{130412, 139252, 4316382} 5267730 0.6732348111658456 5.357538097554097\n",
      "{5267730, 102252} 4316382 0.6727989487516426 4.769356934395063\n",
      "{4316482, 130412} 4316382 0.6727477477477478 4.769331333893115\n",
      "{130412, 8892, 139252} 4316482 0.6722475900558093 4.059497789836306\n",
      "{8792, 139252} 5267730 0.6713192255740658 5.356580304758207\n",
      "{5267730, 5997} 102392 0.670654296875 5.363104926215277\n",
      "{130412} 139252 0.6705855754013113 5.212257335977081\n",
      "{4316482} 5267730 0.6703327300570793 5.356087056999714\n",
      "{130412, 5267730, 8892} 4316482 0.6702673507966515 4.058507670206727\n",
      "{5267730, 22718131} 130412 0.6697338970405372 4.6644808460315685\n",
      "{134932} 139252 0.6695071722766652 5.211718134414758\n",
      "{78552, 139252} 8892 0.6692226335272342 5.2907495832051925\n",
      "{8792, 139252} 8892 0.6690679873930662 5.290672260138109\n",
      "{5267730, 8932} 130412 0.6689244107287997 4.6640761028757\n",
      "{8892, 5997} 102392 0.6688921859545005 5.362223870755027\n",
      "{8792, 5267730} 130412 0.6686550976138829 4.663941446318241\n",
      "{4316482, 8892} 130412 0.6678427419354839 4.663535268479042\n",
      "{4316482, 8892} 139252 0.6678427419354839 5.210885919244167\n",
      "{4316482, 4316382} 5267730 0.6674950298210736 5.354668206881711\n",
      "{4316482, 4316382} 130412 0.6674950298210736 4.663361412421837\n",
      "{5267730, 139252} 4316382 0.6674110465981837 4.766662983318334\n",
      "{4316482, 4316382} 130412 0.6672465208747514 4.663237157948676\n",
      "{4316482, 4316382} 139252 0.6672465208747514 5.210587808713801\n",
      "{102252, 139252} 130412 0.6671554252199413 4.663191610121271\n",
      "{4316482, 130412} 8892 0.6671171171171171 5.289696825000134\n",
      "{4316482, 4316382} 8892 0.6669980119284294 5.28963727240579\n",
      "{102392, 4312482} 5267730 0.6668391101914123 5.35434024706688\n",
      "{134912, 139252} 8892 0.6665944071103403 5.289435469996746\n",
      "{5267730, 22718131} 8892 0.666252176075603 5.289264354479377\n",
      "{8792} 102252 0.6655788876276957 5.1392498987141\n",
      "{102252, 139252} 5267730 0.665060745705907 5.353451064824127\n",
      "{5267730, 134932} 8892 0.6649225617413144 5.2885995473122325\n",
      "{130412, 139252} 8892 0.6645313553607552 5.288403944121953\n",
      "{102392, 5800} 5997 0.6636340662117767 4.9173114149244\n",
      "{102392, 130412} 5267730 0.6630588235294117 5.35245010373588\n",
      "{139252, 5997} 102392 0.6627470602952213 5.359151307925387\n",
      "{4312482, 22718131} 4316482 0.6623867069486405 4.054567348282721\n",
      "{8792, 8892} 102252 0.662004662004662 5.137462785902583\n",
      "{5267730, 5997} 4316382 0.661865234375 4.763890077206741\n",
      "{8892, 102252} 5267730 0.6618556701030928 5.35184852702272\n",
      "{102792, 139252} 8892 0.6613290632506005 5.2868027980668755\n",
      "{5267730, 4762734} 8892 0.6611481975967958 5.286712365239974\n",
      "{134912} 130412 0.6610824742268041 4.660155134624702\n",
      "{134912} 139252 0.6605097365406644 5.207219416546757\n",
      "{22718131} 139252 0.6604820805581986 5.207205588555524\n",
      "{134932, 4316382} 130412 0.6604161315181094 4.659821963270355\n",
      "{139252, 134932} 8892 0.6601612218922359 5.286218877387694\n",
      "{130412, 134932} 4316382 0.6600770218228498 4.762995970930667\n",
      "{5267730, 130412, 4316382} 134912 0.659957627118644 4.250294908514758\n",
      "{11712, 8892} 5267730 0.6594650205761318 5.35065320225924\n",
      "{4312482, 4316482} 130412 0.6592721834496511 4.659249989236126\n",
      "{102392, 102792} 139252 0.658682634730539 5.206305865641695\n",
      "{139252, 4762734} 130412 0.6586251621271076 4.658926478574854\n",
      "{22503880} 130412 0.658008658008658 4.658618226515629\n",
      "{8932} 139252 0.6577925679423183 5.205860832247584\n",
      "{78352} 139252 0.6577054794520547 5.205817288002453\n",
      "{5997, 6446} 5800 0.6575596816976127 5.18314731892973\n",
      "{8892, 8932} 130412 0.656589763988332 4.657908779505466\n",
      "{5267730, 5267750} 4316382 0.6559739655973966 4.76094444281794\n",
      "{139252, 3461} 8892 0.655928175336678 5.284102354109915\n",
      "{4312482, 4316482} 22718131 0.6557826520438684 5.153165034929339\n",
      "{5997, 6446} 102392 0.6554376657824933 5.355496610669023\n",
      "{8792, 139252} 130412 0.6553354344889689 4.657281614755784\n",
      "{78352, 8892} 102392 0.6553258309343104 5.355440693244932\n",
      "{22718131, 139252} 8892 0.6552220888355342 5.283749310859343\n",
      "{102392, 102792} 8892 0.6548502994011977 5.283563416142174\n",
      "{4312482, 5267730} 8892 0.6546457361052185 5.283461134494185\n",
      "{78352} 8892 0.6542808219178082 5.28327867740048\n",
      "{4312482, 139252} 4316482 0.6537356321839081 4.0502418109003555\n",
      "{130412, 4316482, 139252} 134912 0.6533262655711636 4.246979227741018\n",
      "{139252, 4316382} 4316482 0.6523972602739725 4.049572624945387\n",
      "{130412, 4316482, 139252} 5267730 0.6520010601643254 5.346921222053337\n",
      "{130412, 4316482, 139252} 4316382 0.6520010601643254 4.758957990101404\n",
      "{139252, 134932} 130412 0.6506151887993211 4.654921491910961\n",
      "{8892, 5997} 5267730 0.6503461918892186 5.346093787915783\n",
      "{4316482, 5267730} 8892 0.6500519210799586 5.281164226981555\n",
      "{5800, 5997} 102392 0.6496783770410688 5.352616966298311\n",
      "{8892, 134932} 102392 0.6496541855473407 5.352604870551447\n",
      "{134912, 139252} 4316382 0.6494688922610015 4.757691906149742\n",
      "{5267730, 22718131} 4316382 0.6493409599602089 4.757627939999346\n",
      "{102392, 4316382} 134932 0.6489333684487754 5.328987379463002\n",
      "{5267730, 4316382} 8892 0.6483253588516745 5.280300945867413\n",
      "{4312482, 5267750} 8892 0.6482361771328496 5.280256355008\n",
      "{102392, 3461} 8892 0.6482051282051282 5.280240830544139\n",
      "{130412, 8892, 139252} 134912 0.647640791476408 4.24413649069364\n",
      "{8892, 5267750} 130412 0.6475026014568158 4.653365198239708\n",
      "{78352, 139252} 102392 0.6474876334287947 5.351521594492175\n",
      "{139252, 4762734} 8892 0.6466926070038911 5.279484569943521\n",
      "{5267730, 8892, 139252} 4316482 0.6458333333333333 4.0462906614750676\n",
      "{4312482, 139252} 8892 0.6457307060755336 5.279003619479343\n",
      "{3461, 5997} 8892 0.6455242966751917 5.278900414779171\n",
      "{5267730, 4316382} 130412 0.6452494873547505 4.652238641188675\n",
      "{21986963} 5267730 0.6450324513230155 5.3434369176326815\n",
      "{21986963} 139252 0.6450324513230155 5.199480773937933\n",
      "{139252, 5267750} 4316382 0.6445532435740514 4.755234081806267\n",
      "{130412, 4316382} 134912 0.6444797819173104 4.242555985914091\n",
      "{8892, 102252} 102392 0.6443298969072164 5.349942726231385\n",
      "{139252, 5267750} 4316482 0.6443084455324358 4.045528217574619\n",
      "{4312482, 4316482} 5267730 0.6435692921236291 5.342705338032989\n",
      "{4312482, 4316482} 139252 0.6435692921236291 5.19874919433824\n",
      "{5267730, 135652} 8892 0.643260495948932 5.277768514416041\n",
      "{139252, 134932} 4316382 0.6431904963937208 4.754552708216102\n",
      "{5267730, 139252} 8892 0.643144260830728 5.277710396856939\n",
      "{5267730, 8892} 4316382 0.6427240386244282 4.754319479331455\n",
      "{5267730, 139252} 130412 0.642399880899211 4.650813837960905\n",
      "{8892, 134932} 130412 0.6422609110422132 4.650744353032406\n",
      "{5267730, 5997} 8892 0.6420898437500001 5.277183188316576\n",
      "{4312482, 139252} 130412 0.6420361247947455 4.650631959908673\n",
      "{134912, 139252} 4316482 0.6418816388467375 4.04431481423177\n",
      "{102392, 102252} 8892 0.6416837782340863 5.276980155558618\n",
      "{5267750} 139252 0.6408848446815187 5.197406970617185\n",
      "{21986963} 5267730 0.6407888167748378 5.341315100358593\n",
      "{21986963} 4316382 0.6407888167748378 4.753351868406661\n",
      "{102392, 5267730} 8892 0.6406192406929598 5.2764478867880555\n",
      "{5267730} 139252 0.6405683768834637 5.197248736718157\n",
      "{4316442, 5267730} 8892 0.640274949083503 5.276275740983327\n",
      "{78352, 139252} 130412 0.6399375162718042 4.649582655647202\n",
      "{4316482, 5267730} 4316382 0.6398753894080997 4.752895154723292\n",
      "{4316482, 5267730} 139252 0.6398753894080997 5.196902242980475\n",
      "{102392, 139252} 8892 0.6397751994198695 5.27602586615151\n",
      "{4316482, 139252} 4316382 0.6396194739787352 4.752767197008609\n",
      "{4762754} 5267730 0.6396048109965635 5.340723097469455\n",
      "{4762754} 4316382 0.6396048109965635 4.752759865517523\n",
      "{8892, 3461} 102392 0.6393525543753161 5.347454054965435\n",
      "{4316482, 5267730} 130412 0.6392523364485982 4.649240065735599\n",
      "{4316482, 5267730} 139252 0.6392523364485982 5.196590716500724\n",
      "{6440} 5997 0.6388012618296529 4.904895012733338\n",
      "{8892, 3461} 5997 0.6383409205867476 4.9046648421118855\n",
      "{5267730, 130412} 4316482 0.637873754152824 4.042310871884813\n",
      "{22718131} 5267730 0.6376466856961625 5.3397440348192555\n",
      "{4762734} 139252 0.6371900826446281 5.195559589598739\n",
      "{4312482, 5267730} 4316382 0.6370386084005092 4.751476764219496\n",
      "{102392, 6446} 5997 0.6368556701030927 4.9039222168700585\n",
      "{11712, 8892} 139252 0.636059670781893 5.194994383667372\n",
      "{139252, 4762734} 4316482 0.6360570687418937 4.041402529179348\n",
      "{130412, 139252} 4316482 0.6360418071476737 4.041394898382238\n",
      "{8752} 8892 0.6356758329695912 5.273976182926371\n",
      "{102392, 4312482} 8892 0.6355406104500776 5.273908571666614\n",
      "{5793} 8892 0.6352993152197923 5.273787924051472\n",
      "{4316482, 5267730, 139252} 4312482 0.6345539444580978 5.183362760680463\n",
      "{130412, 5267730, 139252} 134912 0.6345307068366165 4.237581448373744\n",
      "{102392, 102792} 5267730 0.634251497005988 5.338046440474168\n",
      "{134912, 5267730} 130412 0.6342367384757934 4.646732266749197\n",
      "{134912, 5267730} 139252 0.6342367384757934 5.194082917514322\n",
      "{4762754} 5267730 0.6331615120274914 5.33750144798492\n",
      "{4762754} 139252 0.6331615120274914 5.193545304290171\n",
      "{134932, 4316382} 102392 0.6329309016182891 5.3442432285869215\n",
      "{78512} 8892 0.6328693122792437 5.2725729225811975\n",
      "{4312482, 5267730} 4316482 0.6321595248196861 4.0394537572182445\n",
      "{139252, 134932} 102392 0.6321595248196861 5.34385754018762\n",
      "{139252, 5997} 8892 0.6312234175631725 5.271749975223162\n",
      "{1586} 1587 0.6311207834602829 5.195409343244963\n",
      "{7452} 78552 0.6305525460455037 5.268063580833748\n",
      "{134912, 5267730} 4316482 0.6305304609682649 4.038639225292534\n",
      "{8792} 139252 0.630249716231555 5.192089406392203\n",
      "{102392, 8892} 139252 0.6301785714285715 5.192053833990711\n",
      "{139252} 5267730 0.6299943725379853 5.335917878240167\n",
      "{4312482, 22718131} 5267750 0.6299093655589124 5.270584210180571\n",
      "{22718131} 4312482 0.6298763082778307 5.18102394259033\n",
      "{8892, 134932} 4316382 0.6296207965657047 4.747767858302094\n",
      "{102392, 3461} 5997 0.6294871794871795 4.900237971562102\n",
      "{102392, 5997} 5267730 0.6290359514540874 5.3354386676982175\n",
      "{5267730, 5267750} 130412 0.6287773128777313 4.644002553950166\n",
      "{4312482, 8892} 130412 0.6287010506208214 4.6439644228217105\n",
      "{33512} 8892 0.6283651970347249 5.270320864958938\n",
      "{8892, 3461} 139252 0.6282245827010622 5.191076839626956\n",
      "{5267730, 5997} 134932 0.628173828125 5.3186076093011145\n",
      "{5267730, 134932} 102392 0.6280870657178736 5.341821310636714\n",
      "{4312482, 5267730} 5267750 0.6279168434450573 5.269587949123643\n",
      "{3461, 5997} 102392 0.6278772378516624 5.341716396703608\n",
      "{5267730, 8892} 130412 0.6273081483991191 4.64326797171086\n",
      "{4316482, 139252} 8892 0.6271218056332774 5.269699169258215\n",
      "{5267750} 4312482 0.6270787574521494 5.179625167177489\n",
      "{4312482, 5267730} 130412 0.6264319049639372 4.6428298499932685\n",
      "{4762754} 8892 0.6262886597938144 5.269282596338483\n",
      "{21986963} 130412 0.6260609086370444 4.642644351829822\n",
      "{4312482, 5267750} 22718131 0.6259694771078309 5.13825844746132\n",
      "{4316482, 8892} 5267730 0.6255040322580645 5.333672708100206\n",
      "{4316482, 8892} 130412 0.6255040322580645 4.642365913640332\n",
      "{102252, 139252} 8892 0.6252618349392544 5.2687691839112025\n",
      "{24097891} 5267730 0.6245806109835776 5.333210997462963\n",
      "{8892, 5997} 3461 0.6241345202769535 5.026222536146391\n",
      "{8892, 5997} 139252 0.6238872403560831 5.188908168454467\n",
      "{134912, 8892} 130412 0.6234432234432234 4.641335509232912\n",
      "{134912, 8892} 139252 0.6234432234432234 5.188686159998037\n",
      "{8892, 3461} 5267730 0.6226605968639353 5.332250990403142\n",
      "{8792, 8892} 130412 0.6226107226107226 4.640919258816662\n",
      "{139252, 5267750} 22718131 0.62203182374541 5.13628962078011\n",
      "{135652, 139252} 130412 0.6214268556329571 4.640327325327779\n",
      "{4312482, 4316482} 4316382 0.6213858424725823 4.743650381255533\n",
      "{102392, 8892} 5267730 0.6207142857142857 5.331277834828317\n",
      "{4312482} 139252 0.6200840015273005 5.187006549040076\n",
      "{102392, 134932} 4316382 0.6200301962757927 4.742972558157137\n",
      "{8792, 139252} 102392 0.619540747411076 5.337548151483315\n",
      "{4316482, 4316382} 4312482 0.6195328031809145 5.175852190041872\n",
      "{102392, 5997} 8892 0.6194183650103046 5.265847448946728\n",
      "{8892, 4316382} 5267730 0.6193053676138927 5.33057337577812\n",
      "{8892, 4316382} 130412 0.6193053676138927 4.639266581318246\n",
      "{4762734} 5267730 0.6190082644628099 5.330424824202579\n",
      "{4316482, 130412} 134912 0.618918918918919 4.229775554414895\n",
      "{4316482, 5267730} 4312482 0.6188992731048807 5.175535425003854\n",
      "{4312482, 8892} 5267750 0.6186723973256925 5.264965726063961\n",
      "{6440} 8892 0.6185218566922036 5.265399194787677\n",
      "{5267730, 22718131} 5267750 0.6182541656304401 5.264756610216335\n",
      "{134912} 5267730 0.6181271477663229 5.3299842658543355\n",
      "{4316482} 130412 0.6181261311429764 4.638676963082788\n",
      "{139252, 5997} 4316382 0.6179634726044534 4.741939196321468\n",
      "{78512} 5267730 0.6179098275503844 5.329875605746366\n",
      "{102252, 139252} 102392 0.6177209886887306 5.336638272122142\n",
      "{134912, 8892} 4316382 0.6170940170940171 4.74150446856625\n",
      "{139252, 5997} 134932 0.6162121591193396 5.312626774798284\n",
      "{130412, 139252} 4316382 0.6159811193526635 4.740948019695574\n",
      "{8792, 8892} 5267730 0.6153846153846153 5.3286129996634815\n",
      "{134912, 5267730} 4316382 0.6152420662497105 4.740578493144096\n",
      "{134912, 5267730} 139252 0.6152420662497105 5.18458558140128\n",
      "{4316382} 5267730 0.6151207464324918 5.32848106518742\n",
      "{4316382} 139252 0.6151207464324918 5.184524921492671\n",
      "{6301} 8892 0.6149394103816241 5.263607971632387\n",
      "{4312482, 5267750} 4762734 0.6147110332749562 5.323162403221007\n",
      "{134912, 130412} 4316382 0.6144682694390297 4.740191594738756\n",
      "{8772} 6301 0.6137875428341061 3.116068016729184\n",
      "{2576} 139252 0.6134854771784233 5.183707286865637\n",
      "{5793} 5267730 0.6134305279434504 5.327635955942899\n",
      "{5800, 5997} 6446 0.6133102424542306 5.111870242394681\n",
      "{5998} 8892 0.6131275809606608 5.262702056921906\n",
      "{22503880} 22718131 0.6129870129870131 5.131767215400911\n",
      "{130412} 5267730 0.612480217047253 5.3271608004948\n",
      "{5267730, 134932} 130412 0.6121808287986605 4.63570431191063\n",
      "{6440} 5267730 0.6117620549797206 5.326801719461034\n",
      "{5267730, 8892, 139252} 102392 0.611574074074074 5.333564814814814\n",
      "{8892, 4316382} 130412 0.6114118177717636 4.635319806397182\n",
      "{8892, 4316382} 139252 0.6114118177717636 5.182670457162307\n",
      "{135652, 139252} 8892 0.6113379774201297 5.26180725515164\n",
      "{139252, 4316382} 5267730 0.6109208523592086 5.3263811181507785\n",
      "{139252, 4316382} 130412 0.6109208523592086 4.635074323690905\n",
      "{4316482, 5267730, 139252} 134912 0.6102236421725239 4.225427916041697\n",
      "{22718131, 139252} 5267750 0.6100840336134454 5.260671544207837\n",
      "{130412, 4316382} 4316482 0.6099500227169469 4.0283490061668745\n",
      "{130412, 4316382} 139252 0.6099500227169469 5.181939559634898\n",
      "{8792} 8892 0.608683314415437 5.260479923649294\n",
      "{33512} 102392 0.608466640655482 5.332011098105518\n",
      "{4316382} 8892 0.608397365532382 5.260336949207766\n",
      "{8892, 139252} 4316382 0.6082704186684968 4.73709266935349\n",
      "{102392, 5997} 139252 0.606594916418594 5.180262006485722\n",
      "{4316442} 4316382 0.6060132760640375 4.7359640980512605\n",
      "{8812} 8892 0.6058481874624474 5.259062360172799\n",
      "{102792} 139252 0.6058205335489086 5.17987481505088\n",
      "{5267730, 139252} 4316482 0.6057763882685723 4.026262188942687\n",
      "{8892, 139252} 102392 0.6055250514756348 5.330540303515594\n",
      "{8792, 102252} 8892 0.6054146237476019 5.258845578315377\n",
      "{8892, 4316382} 4316482 0.6053225078935499 4.026035248755176\n",
      "{22503880} 4316482 0.6049783549783551 4.025863172297579\n",
      "{22503880} 139252 0.6049783549783551 5.179453725765603\n",
      "{4316482, 130412} 5267730 0.604954954954955 5.323398169448652\n",
      "{4316482, 130412} 4316382 0.604954954954955 4.735434937496719\n",
      "{6446} 102392 0.6044555226670821 5.330005539111318\n",
      "{134912, 8892} 5267730 0.6043956043956044 5.323118494168976\n",
      "{134912, 8892} 139252 0.6043956043956044 5.179162350474227\n",
      "{4316382} 130412 0.604006586169045 4.631617190595823\n",
      "{5267750} 8892 0.6030749921556323 5.2576757625193915\n",
      "{130412, 8892} 134912 0.6029046436078731 4.221768416759372\n",
      "{8752, 8892} 139252 0.6026550698100253 5.178292083181438\n",
      "{8812} 102392 0.6026437011816542 5.329099628368604\n",
      "{102392, 5997} 5800 0.6013281428898557 5.155031549525851\n",
      "{6440} 139252 0.6009463722397477 5.177437734396299\n",
      "{8792, 8892} 102392 0.6006993006993007 5.328127428127427\n"
     ]
    }
   ],
   "source": [
    "#import association_rules\n",
    "import imp\n",
    "imp.reload(association_rules)\n",
    "# 读取animation 和 animation_feature\n",
    "animation = pd.read_json(\"./test_data/bilibili_crawler_animation.json\", encoding=\"utf-8\")\n",
    "animation[\"score\"] = animation[\"score\"].fillna('%.1f' % animation[\"score\"].mean())\n",
    "animation[[\"follow\", \"play\"]] = animation[[\"follow\", \"play\"]].applymap(association_rules.trans)\n",
    "animation_feature = pd.read_json(\"./test_data/bilibili_crawler_animation_feature.json\",dtype={\"character_voice_list\": str})\n",
    "animation_feature[[\"tag_list\", \"character_voice_list\", \"character_staff_list\"]] = animation_feature[[\"tag_list\", \"character_voice_list\", \"character_staff_list\"]].applymap(json.loads)\n",
    "\n",
    "# #将关联规则的后项展开\n",
    "rules_df = association_rules.unfold_rules(rules_df)\n",
    "# 对关联规则进行扩展，综合考虑置信度、番剧评分、声优导演等信息\n",
    "rules_weight = {\"confidence\": 0.5, \"score\": 0.5, \"play\": 0.1, \"follow\": 0.1, \"voice\": 0.1, \"staff\": 0.1}\n",
    "rules_df = association_rules.add_score(rules_df, rules_weight, animation, animation_feature)\n",
    "for index,row in rules_df.iterrows():\n",
    "    print(row[\"rules_a\"], row[\"rules_b\"], row[\"confidence\"], row[\"score\"])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 164,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>rules_a</th>\n",
       "      <th>rules_b</th>\n",
       "      <th>confidence</th>\n",
       "      <th>score</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>{140552}</td>\n",
       "      <td>135652</td>\n",
       "      <td>0.888640</td>\n",
       "      <td>5.495017</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>{130412, 4316482, 139252, 4316382}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.916201</td>\n",
       "      <td>5.479021</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>{4762754, 139252, 4316382}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.912545</td>\n",
       "      <td>5.477193</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>{4316442, 4316382}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.900451</td>\n",
       "      <td>5.471146</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>{4316482, 130412, 4316382}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.899230</td>\n",
       "      <td>5.470536</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>{4316482, 139252, 4316382}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.898513</td>\n",
       "      <td>5.470177</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>{4762754, 4316382}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.898070</td>\n",
       "      <td>5.469956</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>{21986963, 4316382}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.896299</td>\n",
       "      <td>5.469070</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>{5267750, 4316382}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.890783</td>\n",
       "      <td>5.466312</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>{4312482, 139252, 4316382}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.888423</td>\n",
       "      <td>5.465132</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>{21986963, 139252}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.887363</td>\n",
       "      <td>5.464602</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>{134912, 139252, 4316382}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.886515</td>\n",
       "      <td>5.464178</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>{8892, 139252, 4316382}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.885755</td>\n",
       "      <td>5.463798</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>{22718131, 4316382}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.884785</td>\n",
       "      <td>5.463313</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>{139252, 134932, 4316382}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.883245</td>\n",
       "      <td>5.462543</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>{130412, 139252, 4316382}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.878763</td>\n",
       "      <td>5.460302</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>{134912, 130412, 4316382}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.878393</td>\n",
       "      <td>5.460117</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>{130412, 8892, 4316382}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.875638</td>\n",
       "      <td>5.458740</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>{4316482, 4316382}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.871769</td>\n",
       "      <td>5.456805</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>{4312482, 4316382}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.867668</td>\n",
       "      <td>5.454755</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>{134912, 4316382}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.863435</td>\n",
       "      <td>5.452638</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>{102392, 139252, 4316382}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.861824</td>\n",
       "      <td>5.451833</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>36</th>\n",
       "      <td>{8932, 4316382}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.861272</td>\n",
       "      <td>5.451557</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>40</th>\n",
       "      <td>{130412, 4316382}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.857792</td>\n",
       "      <td>5.449817</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>41</th>\n",
       "      <td>{4316442, 139252}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.856441</td>\n",
       "      <td>5.449141</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>42</th>\n",
       "      <td>{8892, 4316382}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.855661</td>\n",
       "      <td>5.448751</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>46</th>\n",
       "      <td>{139252, 4316382}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.852930</td>\n",
       "      <td>5.447386</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50</th>\n",
       "      <td>{134932, 4316382}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.851528</td>\n",
       "      <td>5.446685</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>55</th>\n",
       "      <td>{8792, 4316382}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.846774</td>\n",
       "      <td>5.444308</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>60</th>\n",
       "      <td>{4762754, 139252}</td>\n",
       "      <td>5267730</td>\n",
       "      <td>0.844215</td>\n",
       "      <td>5.443028</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>288</th>\n",
       "      <td>{134912, 5267730, 139252}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.719085</td>\n",
       "      <td>4.082916</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>308</th>\n",
       "      <td>{130412, 5267730, 139252}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.713326</td>\n",
       "      <td>4.080037</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>318</th>\n",
       "      <td>{5267730, 130412, 4316382}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.711335</td>\n",
       "      <td>4.079041</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>320</th>\n",
       "      <td>{4312482, 5267730, 139252}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.710316</td>\n",
       "      <td>4.078532</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>339</th>\n",
       "      <td>{134912, 139252, 130412}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.700682</td>\n",
       "      <td>4.073715</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>349</th>\n",
       "      <td>{22718131, 139252}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.696999</td>\n",
       "      <td>4.071873</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>370</th>\n",
       "      <td>{5267730, 139252, 4316382}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.687263</td>\n",
       "      <td>4.067005</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>380</th>\n",
       "      <td>{21986963}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.683974</td>\n",
       "      <td>4.065361</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>391</th>\n",
       "      <td>{4312482, 130412}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.680298</td>\n",
       "      <td>4.063523</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>394</th>\n",
       "      <td>{130412, 4316382}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.678555</td>\n",
       "      <td>4.062652</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>411</th>\n",
       "      <td>{5267730, 22718131}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.673962</td>\n",
       "      <td>4.060355</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>414</th>\n",
       "      <td>{130412, 139252, 4316382}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.673235</td>\n",
       "      <td>4.059991</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>418</th>\n",
       "      <td>{130412, 8892, 139252}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.672248</td>\n",
       "      <td>4.059498</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>423</th>\n",
       "      <td>{130412, 5267730, 8892}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.670267</td>\n",
       "      <td>4.058508</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>451</th>\n",
       "      <td>{4312482, 22718131}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.662387</td>\n",
       "      <td>4.054567</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>483</th>\n",
       "      <td>{4312482, 139252}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.653736</td>\n",
       "      <td>4.050242</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>485</th>\n",
       "      <td>{139252, 4316382}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.652397</td>\n",
       "      <td>4.049573</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>503</th>\n",
       "      <td>{5267730, 8892, 139252}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.645833</td>\n",
       "      <td>4.046291</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>512</th>\n",
       "      <td>{139252, 5267750}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.644308</td>\n",
       "      <td>4.045528</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>523</th>\n",
       "      <td>{134912, 139252}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.641882</td>\n",
       "      <td>4.044315</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>543</th>\n",
       "      <td>{5267730, 130412}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.637874</td>\n",
       "      <td>4.042311</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>549</th>\n",
       "      <td>{139252, 4762734}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.636057</td>\n",
       "      <td>4.041403</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>550</th>\n",
       "      <td>{130412, 139252}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.636042</td>\n",
       "      <td>4.041395</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>563</th>\n",
       "      <td>{4312482, 5267730}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.632160</td>\n",
       "      <td>4.039454</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>568</th>\n",
       "      <td>{134912, 5267730}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.630530</td>\n",
       "      <td>4.038639</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>652</th>\n",
       "      <td>{130412, 4316382}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.609950</td>\n",
       "      <td>4.028349</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>662</th>\n",
       "      <td>{5267730, 139252}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.605776</td>\n",
       "      <td>4.026262</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>665</th>\n",
       "      <td>{8892, 4316382}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.605323</td>\n",
       "      <td>4.026035</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>666</th>\n",
       "      <td>{22503880}</td>\n",
       "      <td>4316482</td>\n",
       "      <td>0.604978</td>\n",
       "      <td>4.025863</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>635</th>\n",
       "      <td>{8772}</td>\n",
       "      <td>6301</td>\n",
       "      <td>0.613788</td>\n",
       "      <td>3.116068</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>681 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                rules_a  rules_b  confidence     score\n",
       "15                             {140552}   135652    0.888640  5.495017\n",
       "0    {130412, 4316482, 139252, 4316382}  5267730    0.916201  5.479021\n",
       "2            {4762754, 139252, 4316382}  5267730    0.912545  5.477193\n",
       "4                    {4316442, 4316382}  5267730    0.900451  5.471146\n",
       "5            {4316482, 130412, 4316382}  5267730    0.899230  5.470536\n",
       "7            {4316482, 139252, 4316382}  5267730    0.898513  5.470177\n",
       "8                    {4762754, 4316382}  5267730    0.898070  5.469956\n",
       "10                  {21986963, 4316382}  5267730    0.896299  5.469070\n",
       "13                   {5267750, 4316382}  5267730    0.890783  5.466312\n",
       "16           {4312482, 139252, 4316382}  5267730    0.888423  5.465132\n",
       "17                   {21986963, 139252}  5267730    0.887363  5.464602\n",
       "18            {134912, 139252, 4316382}  5267730    0.886515  5.464178\n",
       "19              {8892, 139252, 4316382}  5267730    0.885755  5.463798\n",
       "20                  {22718131, 4316382}  5267730    0.884785  5.463313\n",
       "21            {139252, 134932, 4316382}  5267730    0.883245  5.462543\n",
       "22            {130412, 139252, 4316382}  5267730    0.878763  5.460302\n",
       "23            {134912, 130412, 4316382}  5267730    0.878393  5.460117\n",
       "25              {130412, 8892, 4316382}  5267730    0.875638  5.458740\n",
       "26                   {4316482, 4316382}  5267730    0.871769  5.456805\n",
       "28                   {4312482, 4316382}  5267730    0.867668  5.454755\n",
       "33                    {134912, 4316382}  5267730    0.863435  5.452638\n",
       "35            {102392, 139252, 4316382}  5267730    0.861824  5.451833\n",
       "36                      {8932, 4316382}  5267730    0.861272  5.451557\n",
       "40                    {130412, 4316382}  5267730    0.857792  5.449817\n",
       "41                    {4316442, 139252}  5267730    0.856441  5.449141\n",
       "42                      {8892, 4316382}  5267730    0.855661  5.448751\n",
       "46                    {139252, 4316382}  5267730    0.852930  5.447386\n",
       "50                    {134932, 4316382}  5267730    0.851528  5.446685\n",
       "55                      {8792, 4316382}  5267730    0.846774  5.444308\n",
       "60                    {4762754, 139252}  5267730    0.844215  5.443028\n",
       "..                                  ...      ...         ...       ...\n",
       "288           {134912, 5267730, 139252}  4316482    0.719085  4.082916\n",
       "308           {130412, 5267730, 139252}  4316482    0.713326  4.080037\n",
       "318          {5267730, 130412, 4316382}  4316482    0.711335  4.079041\n",
       "320          {4312482, 5267730, 139252}  4316482    0.710316  4.078532\n",
       "339            {134912, 139252, 130412}  4316482    0.700682  4.073715\n",
       "349                  {22718131, 139252}  4316482    0.696999  4.071873\n",
       "370          {5267730, 139252, 4316382}  4316482    0.687263  4.067005\n",
       "380                          {21986963}  4316482    0.683974  4.065361\n",
       "391                   {4312482, 130412}  4316482    0.680298  4.063523\n",
       "394                   {130412, 4316382}  4316482    0.678555  4.062652\n",
       "411                 {5267730, 22718131}  4316482    0.673962  4.060355\n",
       "414           {130412, 139252, 4316382}  4316482    0.673235  4.059991\n",
       "418              {130412, 8892, 139252}  4316482    0.672248  4.059498\n",
       "423             {130412, 5267730, 8892}  4316482    0.670267  4.058508\n",
       "451                 {4312482, 22718131}  4316482    0.662387  4.054567\n",
       "483                   {4312482, 139252}  4316482    0.653736  4.050242\n",
       "485                   {139252, 4316382}  4316482    0.652397  4.049573\n",
       "503             {5267730, 8892, 139252}  4316482    0.645833  4.046291\n",
       "512                   {139252, 5267750}  4316482    0.644308  4.045528\n",
       "523                    {134912, 139252}  4316482    0.641882  4.044315\n",
       "543                   {5267730, 130412}  4316482    0.637874  4.042311\n",
       "549                   {139252, 4762734}  4316482    0.636057  4.041403\n",
       "550                    {130412, 139252}  4316482    0.636042  4.041395\n",
       "563                  {4312482, 5267730}  4316482    0.632160  4.039454\n",
       "568                   {134912, 5267730}  4316482    0.630530  4.038639\n",
       "652                   {130412, 4316382}  4316482    0.609950  4.028349\n",
       "662                   {5267730, 139252}  4316482    0.605776  4.026262\n",
       "665                     {8892, 4316382}  4316482    0.605323  4.026035\n",
       "666                          {22503880}  4316482    0.604978  4.025863\n",
       "635                              {8772}     6301    0.613788  3.116068\n",
       "\n",
       "[681 rows x 4 columns]"
      ]
     },
     "execution_count": 164,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rules_df.sort_values(by='score',inplace=True,ascending=False)\n",
    "rules_df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 170,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['rules_a', 'rules_b', 'confidence', 'score'], dtype='object')"
      ]
     },
     "execution_count": 170,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "rules_df.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 165,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[[['140552'], ['135652']],\n",
       " [['130412', '4316482', '139252', '4316382'], ['5267730']],\n",
       " [['4762754', '139252', '4316382'], ['5267730']],\n",
       " [['4316442', '4316382'], ['5267730']],\n",
       " [['4316482', '130412', '4316382'], ['5267730']]]"
      ]
     },
     "execution_count": 165,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 将规则转换为(rule_a,rule_b)的格式，根据rules的实际情况更改\n",
    "new_rule = []\n",
    "for index,row in rules_df.iterrows():\n",
    "    b=[]\n",
    "    for item in row[0]:\n",
    "        b.append(str(item))\n",
    "    new_rule.append([b,[str(row[1])]])\n",
    "new_rule[:5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 166,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0  rules miss\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0.8006241357525562"
      ]
     },
     "execution_count": 166,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 计算前100条规则的平均准确率\n",
    "result = evaluate_association_rules(new_rule[:100],evaluate_data)\n",
    "result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 167,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0  rules miss\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0.6984146866930883"
      ]
     },
     "execution_count": 167,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 计算第100到200条规则的平均准确率\n",
    "result = evaluate_association_rules(new_rule[100:200],evaluate_data)\n",
    "result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 168,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0  rules miss\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0.7426660868893857"
      ]
     },
     "execution_count": 168,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 计算第200到300条规则的平均准确率\n",
    "result = evaluate_association_rules(new_rule[200:300],evaluate_data)\n",
    "result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 169,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0  rules miss\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "0.7166957931575683"
      ]
     },
     "execution_count": 169,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 计算全部规则的平均准确率\n",
    "result = evaluate_association_rules(new_rule,evaluate_data)\n",
    "result"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "分别对前100条规则、第100到200条规则、第200到300条规则、全部规则进行评估，\n",
    "发现使用靠近前面的规则进行推荐，平均准确率较高，证明了使用关联规则的置信度对规则进行排名有一定的优化效果。\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 100,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{'1587'} {'1', '6', '5', '8'}\n",
      "{'4316482', '4316382', '5267730', '130412'} {'5', '1', '9', '3', '2'}\n",
      "{'4316482', '5267730', '134912'} {'5', '1', '9', '3', '2'}\n",
      "{'4316482', '4316382', '130412'} {'5', '1', '9', '3', '2'}\n",
      "{'4316482', '134912', '130412'} {'5', '1', '9', '3', '2'}\n"
     ]
    }
   ],
   "source": [
    "for rule_a,rule_b in new_rule[:5]:\n",
    "    set_rule_a = set(rule_a)\n",
    "    set_rule_b = set(rule_b)\n",
    "    \n",
    "    print(set_rule_a,set_rule_b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
